Hi, I'm having problems with PIC18F4550 USART. I'm using the usart.h routines, with interrupts enabled for receiving.
I've got a PC that sends group of three bytes (0x55) through a serial port at 9600 baud with no pause between bytes and 100 msec between groups. I have an *low* priority interrupt in the PIC that receives bytes from the USART and toggles on output if the byte received is not 0x55. No other interrupts are running/enabled. I'm observing the output with an oscilloscope. The output never toggles, unless I deliberately send wrong characters. As expected. This works at different baudrates and with different delays between chars and groups. As expected. If I enable my main program loop the problems start. The main loop just checks if a character is received and sends out a char through the USART. Sending is not interrupt driven. Observing the output pin and the PIC USART RX pin I see consistently that after reception of two character (from PC to PIC) the output sometimes toggles. Sometimes it also toggles after the third char. This does not happen all the time but intermittently like once or twice a second. It never toggles after the first character in the group. So the problem happens at about the same time the first character that PIC main program sends completes. If I add a 1 ms (about one char time) between chars sent from the PC , the problem mostly, but not totally, goes away. If I add 5 ms between chars the problem disappears. Changing my receive interrupt to toggle every time a character is sent I see that sometimes interrupts are missing. I've googled a bit and looked the chip errata but not found anything special, USART and interrupts in PIC seem rather straightforward. I'll try to come up with a very small self contained test case, but meanwhile I'd like to know if there are know issues or things I should/could check. br Kusti ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user