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: Stop bits = 1, 1.5, 2...?

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



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

Usart: Stop bits = 1, 1.5, 2...?
PostPosted: Fri May 05, 2006 8:59 am     Reply with quote

So i've searched the Microchip datasheets, the CCS documentation and this forum. So far I am pretty sure about the answer but I'd like the verify here first just in case I missed something.

Is there a way to adjust the length of the stop bit of the hardware USART of a PIC16F7x?

Before you answer: Yes i know about the 9th bit, but I already use it Smile
Still before you answer: No i can't make my own software-based serial port, I need the CPU time and interrupts running.

I basically need a 1.5 stop bit on a 9 bits data communication. I think i'm screwed.
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: Fri May 05, 2006 9:16 am     Reply with quote

Just confirming what you already know - you can't do it with the hardware UART. Its still possible to do it with your own software UART. I have a 18F452 PIC running at 40MHz that has two software UARTs running full duplex at 115Kbps plus a HW UART and a full speed USB interface.

For the software UARTs it requires a timer (preferably two) and an interrupt pin per software RX pin (for start bit detection). In my cast the interrupt handler was coded in ASM but I have test a single SW UART at 115Kbps using the same technique with CCS C.

Disclaimer - it is far easier to do this with an 18F series pic than a 16F series pic because of the hardware interrupt priority support
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah
Guest







PostPosted: Fri May 05, 2006 2:56 pm     Reply with quote

There is a sort of 'trick'.
For receive, you don't need to do anything. Unit set to 1 stop bit, will happily receive data with 1.5 stop bits. For transmit, use the option to control a 'data available' line ('enable=pin' in the use_rs232 setup), and connect this pin 'back' to an interrupt input on the pic. In this interrupt, trigger a hardware CTC timer lasting for half a bit time. When this interrupts, send the next character. You can do the same in software, by checking the transmit shift register empty bit, then waiting for half a bit time, but the hardware interconnection, allows other things to be done while waiting.
It is not easy, but can work.

Best Wishes
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