Having now got that piece of code working it has presented this:
If you remove power to the PIC and then reconnect, it of course first looks for the USB and data as per the Gosub DoUSBin etc. As at this stage the USB databuffers are empty, ie no data being sent, it stores the EEPROM variables as 0, instead of retaining the previously stored numbers.
I have come up with this, what i think, long winded solution.
Where by the top three lines of code read:
Code:
Main:
Gosub DoUSBIN
Gosub CheckData
Gosub DoUSBoUT
And then
Code:
CheckData:
If USBBuffer[9] = 0 Then
Read 1, SecondsDelayOut ' read previously stored
Read 3, MinutesDelayOut ' variables from EEPROM
Read 5, HoursDelayOut ' before they are blanked
SecondsDelayOut = SecondsDelay
MinutesDelayOut = MinutesDelay
HoursDelayOut = HoursDelay
Return
Else
SecondsDelay = USBBuffer[11]
MinutesDelay = USBBuffer[13]
HoursDelay = USBBuffer[15]
Write 1, SecondsDelay
Write 3, MinutesDelay
Write 5, Hoursdelay
EndIf
Return
Obvioulsy in VB when i write the data again, i set BufferOut(10) = 1 to write the new variables.
Is this the easiest way?
Bookmarks