I am trying to get my Brat to be able to store commands that I download from my PC using a VB program that I am in the process of writing. I am running into issues with reliably writing information out to the EEProm. From previous threads I believe the new Pro as 4k of EEProm.
My download function is rather primitive right now, as I am downloading one line with the count of items in the sequence and then a line for each line in the sequence. Each line has the HSERVO values for each of the 6 servos in the Brats movement, plus a time value.
A portion of the code on the brat’s side to receive the information:
GHCEpromStart con 0x110
;
; now lets try to get some serial input from our Host PC
;
serin s_in, i2400, 250, GCHTimeout, [sdec GHCCnt]
; Ok we got a count. If it is -1 then it is a do immediate!
if GHCCnt = -1 then
; now lets try to get some serial input from our Host PC
serin s_in, i2400, 5000, GCHTimeout, [sdec GHCVals(0), sdec GHCVals(1),sdec GHCVals(2),sdec GHCVals(3),sdec GHCVals(4),sdec GHCVals(5),sdec GHCVals(6)]
; We got a command!
gosub movement(tofloat GHCVals(0)) / stepsperdegree, (tofloat GHCVals(1)) / stepsperdegree, (tofloat GHCVals(2)) / stepsperdegree, (tofloat GHCVals(3)) / stepsperdegree, (tofloat GHCVals(4))/ stepsperdegree, (tofloat GHCVals(5)) / stepsperdegree, tofloat GHCVals(6)]
elseif GHCCnt < 10
; so a little check to make sure that count is reasonable.
Writedm GHCEpromStart, [GHCCnt.lowbyte, ghcCnt.highbyte]
servoZeroT = GHCEpromStart + 2
DISABLE WKPINT_3
DISABLE TIMERAINT
for t = 0 to GHCCnt - 1
; read in the number of lines.
serin s_in, i2400, 5000, GCHT2, [sdec GHCVals(0), sdec GHCVals(1),sdec GHCVals(2),sdec GHCVals(3),sdec GHCVals(4),sdec GHCVals(5),sdec GHCVals(6)]
; Now lets write out the movement in EEPROM.
WritedM servoZeroT, [GHCVals(0).lowbyte, GHCVals(0).highbyte, GHCVals(1).lowbyte, GHCVals(1).highbyte, GHCVals(2).lowbyte, GHCVals(2).highbyte, GHCVals(3).lowbyte, GHCVals(3).highbyte, GHCVals(4).lowbyte, GHCVals(4).highbyte, GHCVals(5).lowbyte, GHCVals(5).highbyte, GHCVals(6).lowbyte, GHCVals(6).highbyte]
ServoZeroT = servoZeroT + (7 * 2)
next
ENABLE WKPINT_3
ENABLE TIMERAINT
Right now I am using the serin function parse the input. I may change over to try to simply input the line and parse myself.
But back to the issue at hand. Another part of this program then retrieves the command and calls movement with the results. I have it right now dumping the input back to the serial port. The last one output looks like:
4
1166,-4998,-4998,-1166,4998,4998,500
4998,-1166,-4998,-4998,500,4998,500
1166,4998,4998,1166,-4998,-4998,500
1166,4998,-1,-1,-1,-1,-1
Notice the last line, has the -1s. This is consistent with these settings.
My first attempt was with: GHCEpromStart con 500
With this setting the last two items of line 1 were -1 (the first write address that failed may have been 0x200.
My next attempt was to have GHCEpromStart con 100
With this setting the last value of the second line failed. Address failed about: 0x80
Next was: GHCEpromStart con 0x100
With this the count failed to be written
I am not sure if I am begin very clear here. But the basic question is: Are there alignment or timing issues involved with writing to the EEPROM?
Thanks