View previous topic :: View next topic |
Author |
Message |
Trentino Guest
|
Two Baud Rates |
Posted: Fri Jun 25, 2004 8:14 am |
|
|
I am tring to use two baud rates but it is not working.
here is my code
stuff...
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
stiff...
void Set_4800_Baud(); //sets GPS baud rate to 4800
stuff...
main() {
stuff...
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
usb_wait_for_enumeration();
printf("\r\n\r\n***Enumerated2***\r\n");
stuff...
} // end of main()
#use rs232(baud=49600, xmit=PIN_C6, rcv=PIN_C7)
Set_4800_Baud()
{
signed int8 i;
for (i=0; i<BAUDSTRING_SIZE; i++)
{
putc(BaudString[i]);
delay_ms(2);
}
return;
}
but it does not work. The "stuff..." contains no RS232 code. The line
printf("\r\n\r\n***Enumerated2***\r\n");
should come out as 4800 but it comes out as 9600 |
|
|
Steve H Guest
|
|
Posted: Fri Jun 25, 2004 8:26 am |
|
|
For problems like this I usually llok at the list file and follow the program execution. Usually I will find that the program flow isn't exactly like I thought it would be and one of the Use RS232's is not in the same logical sequence as I thought it would be.
Learning to look at the list file is a useful tool to debugging program problems.
HTH - Steve H. |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Fri Jun 25, 2004 11:15 am |
|
|
try this, at the beginning of your program:
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
then when you want to switch over to 9600, do this:
set_uart_speed(9600);
and when you want to go back to 4800:
set_uart_speed(4800)
This works only with the hardware serial power, which you are using right now (pins C6 and C7) |
|
|
|