The problem is trying to write to the EEPROM in the interrupt routine.
Writing to EEPROM is a slow process.
It takes 6 ms to write a byte, so at 9600 baud, the data is coming in too fast
for the write to work, hence you will get unpredictable results.
Write the data to the EEPROM outside the interupt routine,or reduce the baud rate to 1200 or less.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Yes, I think Mauried is right , because writing eeprom also call an interrupt !
So before you enable receiving any data and storing it in eeprom ,you must verify if last eeprom_write has finished with for instance :On Interrupt EepromReady call verfying_eeprom_ready (it's a suggestion)
If usart-speed is higher than eeprom_write , try to store datas in an array before sending in eeprom
Regards
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
here is my test code:
#chip 16F688, 12 'mhz
#config MCLRE=off, WDT=off
#define USART_BAUD_RATE 9600
InitUsart
On Interrupt UsartRX1Ready call serial_in
lcdcon = 0
dim spot as byte
spot=0
'Set the pin directions
dir portc.5 in ' serial
dir portc.3 out ' led
dir portc.1 out 'up
'Main routine
Start:
set portc.3 on
wait 100 ms
set portc.3 off
wait 100 ms
goto start
sub serial_in
set portc.1 on
if RCIF On Then serdata = RCREG
epwrite spot, serdata
spot = spot + 1
end sub
but i only get a few bytes stored no matter how many i send, but the heartbeat is still running so i know the chip is not locking up
The problem is trying to write to the EEPROM in the interrupt routine.
Writing to EEPROM is a slow process.
It takes 6 ms to write a byte, so at 9600 baud, the data is coming in too fast
for the write to work, hence you will get unpredictable results.
Write the data to the EEPROM outside the interupt routine,or reduce the baud rate to 1200 or less.
Hi,
Yes, I think Mauried is right , because writing eeprom also call an interrupt !
So before you enable receiving any data and storing it in eeprom ,you must verify if last eeprom_write has finished with for instance :On Interrupt EepromReady call verfying_eeprom_ready (it's a suggestion)
If usart-speed is higher than eeprom_write , try to store datas in an array before sending in eeprom
Regards
GC