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

usart receiving bad char

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







usart receiving bad char
PostPosted: Thu May 04, 2006 2:31 pm     Reply with quote

When the usart is eceiving good chars it works flawlessly. But when the usart is receiving bad char's it works for a while the stops. I use the funtion to clear the garbage.


#ifdef UART_ON
if (RCSTA1 & 0x06)
{
output_high(pin_a3);
ch=RCREG; //empty anything that is in the buffer
ch=RCREG;
if (OERR1) {
CREN1=0;
CREN1=1;
}
}
else output_low(pin_a3);

but if the errors come at a high rate it stops receiving all together. the error funtion still is working, the pin a3 is still going up and down, but even if the data is clean the only way to get it to start receiving again is to reset the chip.

Is there a way to reset the uart? or clear other errors?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 04, 2006 2:56 pm     Reply with quote

What PIC are you using ?
Guest








PostPosted: Thu May 04, 2006 3:08 pm     Reply with quote

the pic is 16f648A
Ttelmah
Guest







PostPosted: Thu May 04, 2006 3:25 pm     Reply with quote

You don't show the definitions for the registers, so it is impossible to see any errors that might exist here.
However the problem is almost certainly, that toggling CREN, may toggle the OE fo this peripheral, if there is a character in the input buffer (though you clear it before hand, if it becomes set at this point). If it does so, then the TRIS bit for the receive, will become cleared, and the UART will stop being able to receive data, till this bit is set. There is an erratum for the chip regarding this (the bit is not meant to do this...). Try either setting this bit in the TRIS register after enabling the peripheral, or (if you are using standard IO), perform a dummy 'read' from this bit, which will set the bit.

Best Wishes
Guest








PostPosted: Thu May 04, 2006 4:13 pm     Reply with quote

I attemped to read from the bit and did not help.

what i did next was sent 1000 char at 19.2 k, the 648a was set to 9600. i noticed that the error funtion was running continiously during the send, witch it should. then and sent 1000 char @9600 (no errors were detected) to it, and the interuput did not fire even once. then resent [email protected] and errors were detected again. then reset the chip and sent the 1000 @9600 and it received it ok. then i used another pic to simulate errors. if there is 1 out of 20 errors it works ok, but if i send 1000 char's of error then the uart will not funtion again until reset.
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