View previous topic :: View next topic |
Author |
Message |
iuujin Guest
|
RS232 receive buffer problem in PIC18F252 |
Posted: Mon Apr 17, 2006 9:02 pm |
|
|
hey there,
I have a RS232 interface(on TTL voltages) between my PIC18F252 and a camera called CMUCam.
The pins for the RS232 interfaces are on the the PIC's hardware UART port (RC6 and RC7).
Baud Rate: 152000
I have no trouble transmitting from the PIC to the camera.
when I receive using gets(), I can only receive three times, a character each time. I have read couple times that the receive buffer has 3 characters, but it is not in detail in the datasheet.
Has anyone else seen this problem before?
I do not have this "receive problem" when I am using rs232 voltages to talk to hyperterminal on the computer.
Thanks for all your help!
Iuujin |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Mon Apr 17, 2006 10:04 pm |
|
|
Actually only two characters are buffered. Most likely you are not servicing the serial port fast enough. When this happens an overrun error will occur and the UART will become disabled. If you add the line ERRORS to your use #RS232 line the compiler will reset the UART when this condition occurs. However it still means you are not servicing the serial port fast enough.
The best way to deal with this problem is to implement a UART Rx Interrupt handler.
Andrew _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
iuujin Guest
|
|
Posted: Tue Apr 18, 2006 11:31 am |
|
|
Andrew, thanks for the reply.
I am new to PIC programming and UART handling, so please bear with some of my basic questions.
my PIC18F252 runs at 20 Mhz, I would have thought the baud rate of 115200 would be a piece of cake.
Is using an interrupt handler for UART the general approach to the problem of missing bytes? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Apr 18, 2006 4:26 pm |
|
|
Quote: | my PIC18F252 runs at 20 Mhz, I would have thought the baud rate of 115200 would be a piece of cake. | 115k2 shouldn't be a problem for the PIC but all depends on what you are doing in the rest of your program.
Quote: | Is using an interrupt handler for UART the general approach to the problem of missing bytes? | It is not the easiest solution but it is very flexible. Projects starting with an easier setup polling the receive register have the tendency to grow and get more features until the easy setup gets in the way and the whole program has to be changed into interrupt driven.
It is up to you, whether you want to start with a simple polling based approach as proof of concept and do a redesign later. |
|
|
|