B4R Question formating the eeprom til the end

yaniv hanya

Active Member
Licensed User
i want to give the user the opportunity to format all data on eeprom.

I built this code-
format eeprom:
public Sub formatEepprom(startpoint As Int)
    Private i As Int = 0
    Private endPoint As Int
            
    If startpoint + 40 < eeprom.Size Then
        endPoint = startpoint+40
    Else
        endPoint= eeprom.Size
    End If
            
    Log("formating eeprom from", startpoint, " To ", endPoint)
    Public Clear() As Byte = Array As Byte(0)
    
    For i  = startpoint To endPoint
        eeprom.WriteBytes(Clear,i)
    Next
            
     Log("i=", i, " size ", eeprom.Size)
    
    If i >= eeprom.Size Then
        Main.restartUnit
    Else
        CallSubPlus("formatEepprom", 5000,endPoint)
    End If
End Sub

The reason I call the function in 40 intervals is that it dosent work from start to end… to have to give some delay in the process.
The problem is that the format process stops around position 240 although the eeprom.Size is 1024. I couldn't make it run to 1024.

Do I miss something about the way it work?
 

yaniv hanya

Active Member
Licensed User
I think i found the reason- the function get a byte as a "Tag", and byte can't be above 255...
i switched it to int, and i made it as page global variable, since the callSubPlus order gets only bytes...
and now it is working...
 
Upvote 0

yaniv hanya

Active Member
Licensed User
Forgive my curiosity: where is the faulty function? I see int's everywhere...
it is not a really faulty function.

it's like that- to make the writimg possible i need "some break" between earses, so i use calSubPlus to call the sub again and again. each time with the new position.

the calSubPlus call gets a byte "tag" as parameter. not int, so i can pass the numbers larger than 255...
 
Upvote 0

yaniv hanya

Active Member
Licensed User
thanks for your reply's.

i enclose a screenshot of the intelisence in my B4R IDE, about callSubPlus, you can see it is demand a "tag as Byte".

how ever' if not, i can't understand why it is not working...
 

Attachments

  • screenShot.jpg
    screenShot.jpg
    65.7 KB · Views: 267
Upvote 0
Top