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

Serial 7 bit transmission

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



Joined: 11 May 2006
Posts: 78

View user's profile Send private message

Serial 7 bit transmission
PostPosted: Thu Aug 03, 2006 7:03 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Thu Aug 03, 2006 7:41 am     Reply with quote

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
sjharris



Joined: 11 May 2006
Posts: 78

View user's profile Send private message

Makes sense
PostPosted: Thu Aug 03, 2006 7:51 am     Reply with quote

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.
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