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

How to reset serial port

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



Joined: 04 Oct 2006
Posts: 7

View user's profile Send private message

How to reset serial port
PostPosted: Thu Jan 18, 2007 7:45 am     Reply with quote

I am developing an application for the 18f6722. I have configured it to use rs232 for PORT2, and have enabled the interrupt to detect incoming bytes.
The problem that I'm having is that sometimes, when I boot the device, I don't appear to get traffic on that port, but other times, it works. What I suspect is happening is that when I initially turn on the device, the component on the other end of the serial port sends a burst of traffic (at the wrong baud rate) and overflows the 3 character buffer in the PIC. I think that when this happens, the PIC stops accepting incoming bytes.
My question is: Is there a way to reset the serial port? I've tried disabling and re-enabling interrupts, but that didn't have any effect. I'm looking for some other means of re-initializing the serial port.
Thank you.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 18, 2007 8:32 am     Reply with quote

Search the documentation for "rs232_errors". Also look at the datasheet for your part.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
may26baf



Joined: 04 Oct 2006
Posts: 7

View user's profile Send private message

PostPosted: Thu Jan 18, 2007 10:00 am     Reply with quote

In the spec sheet for the PIC, the lines are just GPIO lines, so there is nothing there about resetting the rs232.
In the help for the compiler, its suggestion is to trace the incoming data line. I know that the problem isn't there because I can receive data sometimes.
Furthermore, I can not find any topic in the compiler help for "rs232_errors".

If you could identify specific commands that are used to reset the serial port on a PIC I would appreciate it.
nousername
Guest







PostPosted: Thu Jan 18, 2007 10:06 am     Reply with quote

put the ERRORS option in your #use rs232 statement to record errors on the serial input and clear them when they occur
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Jan 18, 2007 10:09 am     Reply with quote

The "ERRORS" option has nothing to do with a software based serial com. "ERRORS" is only for a hardware USART.

I think it is closly tied to the OERR bit and then CREN bit used to clear OERR.

What is the pin/port you are using?
like RC6? or RA4??

Ignor this post,...See below.. This is the second hardware EUSART. You threw me by calling them GPIO lines.


Last edited by treitmey on Thu Jan 18, 2007 11:26 am; edited 3 times in total
may26baf



Joined: 04 Oct 2006
Posts: 7

View user's profile Send private message

PostPosted: Thu Jan 18, 2007 10:24 am     Reply with quote

I see where your going.

To answer your question, the serial port is configured as
#use rs232 (baud=4800, xmit=PIN_G1, rcv=PIN_G2, stream=PORT2)

So, now a newbie type of question. How do I access the specific registers? I take it that I need to read RCSTAx and if check the OERR bit. Furthermore, my problem may be that I need to clear the CREN bit. How do I go about addressing specific registers like this?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Jan 18, 2007 11:22 am     Reply with quote

OK. This is a HARDWARE EUSART implimentation.
(the second EUSART)
The ERRORS directive should work for this. But if you want to
you can access the bits with a #byte and/or #bit.
may26baf



Joined: 04 Oct 2006
Posts: 7

View user's profile Send private message

Thanks
PostPosted: Thu Jan 18, 2007 8:29 pm     Reply with quote

Thanks everyone for your answers. With your help I was able to read the RCSTAx register and verify that in fact the OERR bit was getting set. Once I determined that, I was able to go in and reset the CREN bit, to re-enable data on the port.
Matias



Joined: 12 Sep 2005
Posts: 5

View user's profile Send private message

RS232_errors, do not disable it!
PostPosted: Fri May 18, 2007 11:33 am     Reply with quote

From the CCS Manual:

Warning:
The PIC UART will shut down on overflow (3 characters received by the
hardware with a GETC() call). The "ERRORS" option prevents the shutdown by detecting the condition and resetting the UART.

It is a good idea to include always ERRORS in #use RS232 declaration, specially when you are developping plug&play devices, the bus may be running before you configure the UART
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