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 support@ccsinfo.com

UART flow control of PIC18F6720

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



Joined: 20 Aug 2004
Posts: 5

View user's profile Send private message

UART flow control of PIC18F6720
PostPosted: Mon Aug 30, 2004 2:50 am     Reply with quote

Hi folks,

I am using the UART 1 (RC6, RC7, GND) of PIC18F6720 for a serial communication. But there is some problem.

If PIC received data, the data is correct. But when the sender transmitt more bytes continuiously, without delay between each bytes, after some byte, the PIC stops receiving, and does not react the serial event any more. When I insert some delay between each byte (e.g. 50ms), all data could be received correctly, and the PIC stays in a normal status. When I send data from PIC to the other device, all data are correctly received. Because the device I used to communicate with PIC has a higher working frequenz (PIC's osc is 20MHz, the other is 73.7MHz), so I thought it should be a problem of flow control.

Someone could tell me, how could I make a flow control on UART with only 3 pins (RC6, RC7, GND), and how can turn the PIC from the overflow status back to work?

Any tip is appreciate!

Wanli
alexbilo



Joined: 01 Jun 2004
Posts: 39
Location: Trois-Rivières

View user's profile Send private message

PostPosted: Mon Aug 30, 2004 5:24 am     Reply with quote

Hi,

Your problem looks effectively as a flow control problem. However, hardware flow control needs two more pins to be implemented. If you need fast communication and prefer to avoid adding delays to make things work right, you can use the serial port interrupts. This way, instead of checking on the serial port data once in a while (as in a loop), you'll read the data as soon as it arrives, avoiding most of overflow problems.

Good luck,
_________________
Alex
wanli



Joined: 20 Aug 2004
Posts: 5

View user's profile Send private message

PostPosted: Mon Aug 30, 2004 6:20 am     Reply with quote

Hi,

Thank you for your reply.

But problem is, I do use Interrupt routine to handle with the Serial Event. But the PIC stops receiving still, and It cannot react any other coming data.

The code is as following:

#use rs232(baud = 115200, XMIT = PIN_C6, RCV = PIN_C7, BITS = 8, PARITY = N)


#int_RDA
RDA_isr()
{
char buff;

buff = getc();
putc(buff);
}


void main()
{

enable_interrupts(INT_RDA);
enable_interrupts(global);

......


}

Is there something wrong?

Wanli
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Add the ERRORS keyword
PostPosted: Mon Aug 30, 2004 9:37 am     Reply with quote

The UART is hanging when it encounters a receive error. You need to add the ERRORS keyword to the USE RS232 statement so it will clear serial receive errors.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Aug 30, 2004 10:20 am     Reply with quote

The putc also probably wait until the character is transmit which is the cause of your problem. It takes just as long to receive the char as it does to send it. You should receive the chars into a buffer and transmit them out of the buffer. The speed of the processors is not a factor in the code that you posted.
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Buffer routine
PostPosted: Mon Aug 30, 2004 11:52 am     Reply with quote

Here is a buffer routine I posted earlier that might be of use....

http://www.ccsinfo.com/forum/viewtopic.php?t=20347
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