View previous topic :: View next topic |
Author |
Message |
cchappyboy
Joined: 03 Dec 2008 Posts: 45
|
question about USART change its baud rate during the process |
Posted: Thu Jan 14, 2010 12:20 pm |
|
|
How can I change baud rate after I received data and change back again after send out and so on ? For example the USART set to #use rs232(baud=9600, xmit=pin_c6,rcv=pin_c7) and I used interrupt to receive data. After I got enough data I want to send out data but need different baud rate for example #use rs232(baud=4800, xmit=pin_c6,rcv=pin_c7) what should I do. Do I need disable interrupts and after initial enable it again?
I am appreciate for any concern... |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Thu Jan 14, 2010 12:52 pm |
|
|
I change the Usart register values on the fly.
Check the USART registers, mainly SPBRG...
This is for a 877 running at 20 Mhz if I remember correctly.
PBP Code....
SELECT Case Tmp
Case 0 '57,600 SEE NOTE ON & ON
SPBRG = 21
CASE 1 '38400 ON & OFF
SPBRG = 32
CASE 2 '19,200 OFF & ON
SPBRG = 64
Case 3 '9600 OFF & OFF
SPBRG = 129
End; |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 14, 2010 1:19 pm |
|
|
Download the CCS manual.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in this section. It has a list of CCS functions that handle RS-232:
Quote: |
BUILT-IN-FUNCTIONS
RS-232
|
There are one or two CCS functions that let you change the baud rate of
the hardware UART. You don't have to write directly to the SPBRG
register. It's easier to use the functions. |
|
|
|