View previous topic :: View next topic |
Author |
Message |
davt
Joined: 07 Oct 2003 Posts: 66 Location: England
|
correct baudrate setting? |
Posted: Fri Oct 29, 2004 9:33 am |
|
|
Hi all
I am trying to set up the baudrate in a 16F767 running at 16.0 mhz, to 250 000.
Can someone please confirm that I have got my settings right from the code below:
spbrg=0x00; // set up
brgh=low; // baudrate to 250.000
sync=0; // enable asynchronous reception
spen=1; // serial port enabled - rc7/rx/dt , rc6/tx/ck pins as serial port pins
rx9=1; // 9 bit reception
Many thanks.
Dave |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Oct 29, 2004 10:53 am |
|
|
Why not:
#use rs232(baud=250000,xmit=rc7,rcv=rc6)
The compiler has no problem with oddball baud rates. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
davt
Joined: 07 Oct 2003 Posts: 66 Location: England
|
|
Posted: Mon Nov 01, 2004 9:21 am |
|
|
Hi Doug
Thanks for your reply.
I need to use the internal hardware usart, I thought the # use rs232 was the software usart?
But any way I want to use the settings:
spbrg=0x00; // set up
brgh=low; // baudrate to 250.000
sync=0; // enable asynchronous reception
spen=1; // serial port enabled - rc7/rx/dt , rc6/tx/ck pins as serial port pins
rx9=1; // 9 bit reception
Will these settings give me 250.000 baudrate @ 16.000 mhz.
Thanks again
Dave |
|
![](templates/subSilver/images/spacer.gif) |
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Mon Nov 01, 2004 9:43 am |
|
|
Dave,
The #use rs232 statement works for both hardware AND software USART's. The compiler recognizes that you want to use the hardware USART if:
1. the device supports a hardware USART
2. you have specified the hardware USART pins
Otherwise the compiler just creates a software USART with the pins specified. _________________ John Morley |
|
![](templates/subSilver/images/spacer.gif) |
davt
Joined: 07 Oct 2003 Posts: 66 Location: England
|
|
Posted: Mon Nov 01, 2004 10:10 am |
|
|
Hi John
How do I incorporate 9th bit reception?
Many thanks.
Dave |
|
![](templates/subSilver/images/spacer.gif) |
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Mon Nov 01, 2004 10:34 am |
|
|
Dave,
One of the options in the #use rs232 state will do this. Insert Bits=9
#use rs232(baud=9600, xmit=PIN_A2, rcv=PIN_A3, bits=9, .......)
Valid number for Bits= range from 5 to 9.
Good Luck! _________________ John Morley |
|
![](templates/subSilver/images/spacer.gif) |
|