|
|
View previous topic :: View next topic |
Author |
Message |
kusterh Guest
|
multiple #use RS232 settings on one usart |
Posted: Fri Jan 31, 2003 4:42 am |
|
|
Hi,
I've got a problem using multiple settings on the same (built in) usart.
In my application the usart is connected to a modem, and this modem runs in two modes:
- 19k2 baud, 8n1
- 9600 baud, 8e1
So in my program I have to switch between these two modes depending on the state of the modem and I can't figure out how to do this.
I've tried the following:
#use RS232 (...., STREAM=x)
#use RS232 (...., STREAM=y)
fprintf(x,...);
fprintf(y,...);
Here x and y should correspond to the same usart, with different settings, but this doesn't work, all output is done with the last #use setting.
Also tried:
#use RS232 (....)
void putcx(char)
#use RS232 (....)
void putcy(char)
printf(putcx,...);
printf(putcy,...);
This also doesn't work, again only the last #use setting is used.
At last I also tried this:
(in the main code before each printf line)
#use RS232 (....)
printf(....);
You guessed right, this also doesn't work, all data is output with the same settings. :-(
Does anyone know how this can be done ?
Thanks,
Herman
___________________________
This message was ported from CCS's old forum
Original Post ID: 11149 |
|
|
Tomi Guest
|
Re: multiple #use RS232 settings on one usart |
Posted: Fri Jan 31, 2003 6:22 am |
|
|
As I know there is no "on-the-fly" config setting by #use rs232 for built-in UART. The hardware is initiated at startup as your last #use line says.
The speed part of your problem is simple: just use "Set_UART_Speed(baudrate)"
The parity part could be more complicated.
Maybe the best solution is to set up the UART for 9-bit data and write your own parity calc./check function with an input bit to indicate your needs. (If no parity is necessary then it is equivalent with a 2-stop-bits transmission and an ignored parity receive.)
:=Hi,
:=
:=I've got a problem using multiple settings on the same (built in) usart.
:=In my application the usart is connected to a modem, and this modem runs in two modes:
:=- 19k2 baud, 8n1
:=- 9600 baud, 8e1
:=So in my program I have to switch between these two modes depending on the state of the modem and I can't figure out how to do this.
:=I've tried the following:
:=#use RS232 (...., STREAM=x)
:=#use RS232 (...., STREAM=y)
:=fprintf(x,...);
:=fprintf(y,...);
:=Here x and y should correspond to the same usart, with different settings, but this doesn't work, all output is done with the last #use setting.
:=Also tried:
:=#use RS232 (....)
:=void putcx(char)
:=#use RS232 (....)
:=void putcy(char)
:=printf(putcx,...);
:=printf(putcy,...);
:=This also doesn't work, again only the last #use setting is used.
:=At last I also tried this:
:=(in the main code before each printf line)
:=#use RS232 (....)
:=printf(....);
:=You guessed right, this also doesn't work, all data is output with the same settings. :-(
:=
:=Does anyone know how this can be done ?
:=Thanks,
:=
:=Herman
___________________________
This message was ported from CCS's old forum
Original Post ID: 11152 |
|
|
kusterh Guest
|
Re: multiple #use RS232 settings on one usart |
Posted: Fri Jan 31, 2003 7:30 am |
|
|
<font face="Courier New" size=-1>I was wondering some more: I don't have to use the usart (the amount of data i have to send to the modem is fairly low), so if i used a bitbanged rs232 interface (i.e. #use RS232 with some general io pins as tx and rx) would the compiler switch correctly between even and no parity ?
I just looked into the generated .lst file and it looks like the generated assembly code indeed is different now for the two settings. For now I can't test it any further because this involves hardware modifications and these are not possible.
:=As I know there is no "on-the-fly" config setting by #use rs232 for built-in UART. The hardware is initiated at startup as your last #use line says.
:=The speed part of your problem is simple: just use "Set_UART_Speed(baudrate)"
:=
:=The parity part could be more complicated.
:=Maybe the best solution is to set up the UART for 9-bit data and write your own parity calc./check function with an input bit to indicate your needs. (If no parity is necessary then it is equivalent with a 2-stop-bits transmission and an ignored parity receive.)
:=
:=:=Hi,
:=:=
:=:=I've got a problem using multiple settings on the same (built in) usart.
:=:=In my application the usart is connected to a modem, and this modem runs in two modes:
:=:=- 19k2 baud, 8n1
:=:=- 9600 baud, 8e1
:=:=So in my program I have to switch between these two modes depending on the state of the modem and I can't figure out how to do this.
:=:=I've tried the following:
:=:=#use RS232 (...., STREAM=x)
:=:=#use RS232 (...., STREAM=y)
:=:=fprintf(x,...);
:=:=fprintf(y,...);
:=:=Here x and y should correspond to the same usart, with different settings, but this doesn't work, all output is done with the last #use setting.
:=:=Also tried:
:=:=#use RS232 (....)
:=:=void putcx(char)
:=:=#use RS232 (....)
:=:=void putcy(char)
:=:=printf(putcx,...);
:=:=printf(putcy,...);
:=:=This also doesn't work, again only the last #use setting is used.
:=:=At last I also tried this:
:=:=(in the main code before each printf line)
:=:=#use RS232 (....)
:=:=printf(....);
:=:=You guessed right, this also doesn't work, all data is output with the same settings. :-(
:=:=
:=:=Does anyone know how this can be done ?
:=:=Thanks,
:=:=
:=:=Herman</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11157 |
|
|
Tomi Guest
|
Re: multiple #use RS232 settings on one usart |
Posted: Fri Jan 31, 2003 9:41 am |
|
|
The answer is theoretically "yes" (but IMHO you have to check the code and have to choose a version what really does it )
:=so if i used a bitbanged rs232 interface (i.e. #use RS232 with some general io pins as tx and rx) would the compiler switch correctly between even and no parity ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 11162 |
|
|
|
|
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
|