CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

changing rs232 baud rates

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Neil Grant
Guest







changing rs232 baud rates
PostPosted: Wed Aug 20, 2003 5:11 am     Reply with quote

hi,

I need to setup a modem that could be set at any baud rate so I tried to do:

#use rs232(baud=19200,xmit=C6,rcv=C7,...
printf("\n\rAT+IPR=2400")
#use rs232(baud=9600,xmit=c6,...
printf("\n\rAT+IPR=2400")

to make sure it is set to 2400 but all the #use rs232 statements create code at the beginning of the program which the pic runs through at boot up and sets the speed to 19200 then 9600 ... etc and the pic ends up in the last speed rather than changing between them. I have tried using streams eg:

#use rs232(baud=19200,xmit=C6,rcv=C7,stream=str1)
#use rs232(baud=9600,xmit=C6,rcv=C7,stream=str2)
fprintf(str1,...
fprintf(str2,...

but this results in the same problem.

the only way I have managed to change speed is by manually writing to the SPBRG register. I am using the 16F876 and the lastest version of mplab (6.3) and picc (3.173)

regards

Neil Grant
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517103
R.J.Hamlett
Guest







Re: changing rs232 baud rates
PostPosted: Wed Aug 20, 2003 6:47 am     Reply with quote

:=hi,
:=
:=I need to setup a modem that could be set at any baud rate so I tried to do:
:=
:=#use rs232(baud=19200,xmit=C6,rcv=C7,...
:=printf("\n\rAT+IPR=2400")
:=#use rs232(baud=9600,xmit=c6,...
:=printf("\n\rAT+IPR=2400")
:=
:=to make sure it is set to 2400 but all the #use rs232 statements create code at the beginning of the program which the pic runs through at boot up and sets the speed to 19200 then 9600 ... etc and the pic ends up in the last speed rather than changing between them. I have tried using streams eg:
:=
:=#use rs232(baud=19200,xmit=C6,rcv=C7,stream=str1)
:=#use rs232(baud=9600,xmit=C6,rcv=C7,stream=str2)
:=fprintf(str1,...
:=fprintf(str2,...
:=
:=but this results in the same problem.
:=
:=the only way I have managed to change speed is by manually writing to the SPBRG register. I am using the 16F876 and the lastest version of mplab (6.3) and picc (3.173)
:=
:=regards
:=
:=Neil Grant
Look in the manual, at 'set_uart_speed'...

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517105
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Re: changing rs232 baud rates
PostPosted: Wed Aug 20, 2003 6:51 am     Reply with quote

:=hi,
:=
:=I need to setup a modem that could be set at any baud rate so I tried to do:
:=
:=#use rs232(baud=19200,xmit=C6,rcv=C7,...
:=printf("\n\rAT+IPR=2400")
:=#use rs232(baud=9600,xmit=c6,...
:=printf("\n\rAT+IPR=2400")
:=
:=to make sure it is set to 2400 but all the #use rs232 statements create code at the beginning of the program which the pic runs through at boot up and sets the speed to 19200 then 9600 ... etc and the pic ends up in the last speed rather than changing between them. I have tried using streams eg:
:=
:=#use rs232(baud=19200,xmit=C6,rcv=C7,stream=str1)
:=#use rs232(baud=9600,xmit=C6,rcv=C7,stream=str2)
:=fprintf(str1,...
:=fprintf(str2,...
:=
:=but this results in the same problem.
:=
:=the only way I have managed to change speed is by manually writing to the SPBRG register. I am using the 16F876 and the lastest version of mplab (6.3) and picc (3.173)
:=
:=regards
:=
:=Neil Grant
This works for me
#use rs232(STREAM=GPS,baud=9600, xmit=PIN_c6, rcv=PIN_c7, parity=N, bits=8)
and in the code where you need to switch baud rate
set_uart_speed(4800,GPS);
___________________________
This message was ported from CCS's old forum
Original Post ID: 144517106
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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