View previous topic :: View next topic |
Author |
Message |
Falgellus
Joined: 12 Feb 2006 Posts: 8
|
Serial problem after eeprom write |
Posted: Mon Feb 20, 2006 4:21 pm |
|
|
Anyone has just had a problem on serial after a write_eeprom function??
I'm using a 16f876 pic which performs a control of an automatic window open close motion. I control the micro on site or by a master pc connected to the normal serial bus. All is ok if I do not save the position of the window in the EEprom using
write_eeprom ( EPAR_SOC_POS , Position );
but if I uncomment it and begin to call it, I see a problem on the serial bus. It seems not to answer to the master calls.
The bus is controlled using an #INT_RDA interrupt.
THANK YOU FOR ANSWERS.
Paolo |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Mon Feb 20, 2006 6:09 pm |
|
|
An EEPROM write puts the PIC to sleep for about 1 to 5ms (depending on the PIC). You may lose interrupts during this time. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Falgellus
Joined: 12 Feb 2006 Posts: 8
|
|
Posted: Tue Feb 21, 2006 1:29 am |
|
|
Quote: | An EEPROM write puts the PIC to sleep for about 1 to 5ms (depending on the PIC). You may lose interrupts during this time.
_________________
Regards, Andrew |
Ok, but the serial problem arises from the write eeprom call and goes on forever after it, even if I do not call anymore the function. From that point on I cannot more communicate with the pic.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 21, 2006 1:41 am |
|
|
The UART is locking up when the receiver's buffer is overrun.
To prevent this, add the ERRORS parameter as shown below.
You'll still lose chars that aren't fetched in time, but at least
the UART won't lock up.
Quote: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//=========================
void main()
{
while(1);
} |
|
|
|
|