![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Luiz Guest
|
Two serial and several speeds |
Posted: Wed Jun 03, 2009 7:05 am |
|
|
Hello to all
As I do to change the speed of the stream COM2,
#use rs232 (baud=10400, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)
set_uart_speed (9600); / / it WORKS LIKE THIS
set_uart_speed (19200);
set_uart_speed (4800);
Is it here as I can do to change the speed?
#use rs232 (baud=9600, parity=N, rcv=PIN_A4, bits=8, STREAM=COM2)
??????
???
?????
?????
Luiz. |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Wed Jun 03, 2009 7:57 am |
|
|
According to the CCS manual set_uart_speed() provides for an optional Stream parameter
Quote: | set_uart_speed( )
Syntax: set_uart_speed (baud, [stream, clock])
Parameters: baud is a constant 100-115200 representing the number of bits per second.
stream is an optional stream identifier.
clock is an optional parameter to indicate what the current clock is if it is
different from the #use delay value
|
_________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
Luiz Guest
|
Two serial and several speeds |
Posted: Wed Jun 03, 2009 8:20 am |
|
|
Would it be like this, but and how much the clock?
set_uart_speed(9600,[COM2, ??);
set_uart_speed(10400,[COM2, ??);
set_uart_speed(4800,[COM2, ??); |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Wed Jun 03, 2009 8:22 am |
|
|
The clock parameter is also optional so:
set_uart_speed(9600,COM2); should be all you need. _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
Luiz Guest
|
Two serial and several speeds |
Posted: Wed Jun 03, 2009 9:08 am |
|
|
I am using like this.
Code: |
#include < 18F2685.h>
#use delay (clock = 8000000)
#use rs232 (baud=19200, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)
#use rs232 (baud=19200, parity=N, rcv=PIN_A4, bits=8, STREAM=COM2)
#int_RDA
void RDA_isr () {CK [PD] = getch (); PD++;IF (PD==0) ck [2] = 0;IF (PD==2) PD=0; }
void main (void)
{
set_uart_speed (4800);
putc (0x70);
delay_ms (10);
rx=CK [0];
if (rx==0x0D){
PD=0;
set_uart_speed (4800, COM2);
fputc (0x0A);
delay_ms (10);
set_uart_speed (9600, COM2);
rx1=fgetc (COM2);
// Here it doesn't work, the speed doesn't change!
} |
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Jun 03, 2009 5:12 pm |
|
|
From the CCS manual Quote: | Syntax: set_uart_speed (baud, [stream, clock])
Parameters: baud is a constant 100-115200 representing the number of bits per second.
stream is an optional stream identifier.
clock is an optional parameter to indicate what the current clock is if it is
different from the #use delay value
Returns: undefined
Function: Changes the baud rate of the built-in hardware RS232 serial port at run-time.
Availability: This function is only available on devices with a built in UART. | The stream on COM2 does not use a hardware UART, so you can't change the baudrate this way.
Solutions to change the baudrate for a soft UART have been posted on this forum. |
|
![](templates/subSilver/images/spacer.gif) |
Luiz Guest
|
Two serial and several speeds |
Posted: Thu Jun 04, 2009 6:37 am |
|
|
Could you give an example? |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Jun 04, 2009 11:31 am |
|
|
Like I said, solutions have been posted on this forum before, use the Search function of this forum to find them. I don't have time now to search these solutions so why don't you give it a try. If you can't find them, post again. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|