bugfix

Oct 26, 2003 0 Replies

Bugfix (the bit order in the rbf file is revers)



------------------------ Private Sub Command1_Click() Dim filelength As Long Dim l As Long Dim ok As Boolean Dim rs As Byte Dim b As Byte Dim chipid As Byte Dim i As Integer Dim tb As Byte



For l = 0 To 524287 bytebuffer(l) = 255 Next l



chipid = ReadID If chipid = 16 Then MsgBox "ChipID: EPCS1" Else If chipid = 17 Then MsgBox "ChipID: EPCS4" Else MsgBox "no configuration device found" Exit Sub End If End If


CommonDialog1.CancelError = True On Error GoTo ErrHandler CommonDialog1.Flags = cdlOFNHideReadOnly CommonDialog1.Filter = "Alle Dateien (*.*)|*.*|" & "AS File (*.rbf)|*.rbf" CommonDialog1.FilterIndex = 2 CommonDialog1.ShowOpen



Open CommonDialog1.FileName For Binary Access Read As #1 Seek #1, 1 filelength = LOF(1) For l = 0 To (filelength - 1)



Get #1, l + 1, b



tb = 0



For i = 1 To 8 tb = tb \ 2 If b > 127 Then tb = tb + 128 b = b - 128 End If b = b * 2 Next i bytebuffer(l) = tb Next l



Close #1


WriteEnable EraseBulk Do rs = ReadStatus Loop Until (rs Mod 2) = 0



For l = 0 To (filelength - 1) WriteEnable b = bytebuffer(l) WriteB l, b Do rs = ReadStatus Loop Until (rs Mod 2) = 0



If (l Mod 100) = 0 Then Form1.Caption = "programming: " + Str(1 + l * 100 \ filelength) + "%" DoEvents End If



Next l



ok = True For l = 0 To (filelength - 1) If bytebuffer(l) ReadB(l) Then ok = False End If



If (l Mod 100) = 0 Then Form1.Caption = "verifing: " + Str(1 + l * 100 \ filelength) + "%" DoEvents End If


Next l



If ok Then MsgBox "OK" Else MsgBox "NOT OK" End If


Exit Sub



ErrHandler: MsgBox "File Open Error" Close #1 End Sub


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required