CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 receive buffer problem in PIC18F252

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
iuujin
Guest







RS232 receive buffer problem in PIC18F252
PostPosted: Mon Apr 17, 2006 9:02 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Apr 17, 2006 10:04 pm     Reply with quote

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







PostPosted: Tue Apr 18, 2006 11:31 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 18, 2006 4:26 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group