|
|
View previous topic :: View next topic |
Author |
Message |
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
Usart: Stop bits = 1, 1.5, 2...? |
Posted: Fri May 05, 2006 8:59 am |
|
|
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
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
|
|
Posted: Fri May 05, 2006 9:16 am |
|
|
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
|
|
Posted: Fri May 05, 2006 2:56 pm |
|
|
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 |
|
|
|
|
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
|