Hi Chris,
EEPROM is already a reserved word.
So in your code, you should be using a different name for EEPROM subroutine, say WriteRom.
Code:
EEPROM 0,[0,0]
'This will write 0 to EEPROM location 0
'and 0 to EEPROM location 1.
'works only during the programming of PIC
'Not each time PIC powers up
Beep var byte
Flash var byte
Gosub readrom
'Since EEPROM locations 0 and 1 have known values now,
'we can read and store them.
'This will be done each time PIC powers up.
'So each time PIC powers up we will get the last saved values.
Start:
if portb.4=1 then
beep=beep+1
gosub WriteRom 'We Write the new value into EEPROM.
gosub ReadRom 'Then we read it right away and store it.
if beep=1 then high portb.0
endif
if portb.3=1 then
flash=flash+1
gosub WriteRom 'We Write the new value into EEPROM.
gosub ReadRom 'Then we read it right away and store it.
if flash=2 then high portb.1
endif
goto start
WriteRom:
write 0, beep 'Takes approx. 10mSec to complete.
pause 15
write 1, flash
pause 15
return
ReadRom:
read 0, beep 'Reading is almost instantenous
read 1, flash
return
end
- In your code, when will you "low" the ports after you pull them high?
- Pulling the ports high is(are) inside the IF statements; are not they supposed to be outside the IF statements but inside the main loop?
-----------------------------------------------
Bookmarks