![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
sjharris
Joined: 11 May 2006 Posts: 78
|
Serial 7 bit transmission |
Posted: Thu Aug 03, 2006 7:03 am |
|
|
I have successfully set up 7 bit transmitter and receiver pins using a PIC16F77, using the non standard USART/SCI pins. (A1 and A2)
I am using a baud of 19200 and all seems to work ok. But when I try to put baud up to 57600 (XTAL 3.6864 MHz) the software USART falls over, it wont compile.
Is there a maximum speed that the SW UART can handle?
This baud rate works fine on the proper USART pins on the PIC. But come to use it on a SW UART abnd it says Baud Rate out of range.
Any ideas
Cheers SH |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Aug 03, 2006 7:41 am |
|
|
If you think about it for a moment. The software 'UART', has to shift the byte to send by one bit, take the bit generated, and output this on a port pin, loop round an repeat this, all in a 'bit time'. The loop itself, also needs to have a counter to give the right number of bits, so you can reckon on the loop needing perhaps 8 instruction times on it's own. The rotation is another three instruction times, the output, about another 6 instruction times in total.
Receive is similar. Here you need to wait looking for the falling edge of the incoming line, then wait 1.5 bit times, retrieve the bit, and rotate this bit into the result byte, again counting as you go.
In general, you can probably reckon that to do the job reasonably well, will probably require a minimum of about 17 instruction times per bit. With your master clock of 3.6864Mhz, you execute 921600 instructions/sec. 17 instructions per bit, gives a 'maximum' useable rate, of 54211bps. 38400ps, should work for you, but 57600, won't.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
sjharris
Joined: 11 May 2006 Posts: 78
|
Makes sense |
Posted: Thu Aug 03, 2006 7:51 am |
|
|
That makes sense, So if I increase my clock to some other frequency, say 20MHz then it should be able to cope?
Do I have to do any calculations , like with HW UART to get the Baud rate correct or does the SW do that for you, i.e. pick any value and SW will manage?
Thanks for help. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|