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

How to change the Parity, odd or even, on the fly using

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Got PIC



Joined: 21 Mar 2008
Posts: 10

View user's profile Send private message

How to change the Parity, odd or even, on the fly using
PostPosted: Fri Mar 21, 2008 8:23 pm     Reply with quote

I'm looking to change the RS232 parameters such as parity, stop bits, on the FLY. I have some code that allows a user to change the RS232 paramters and the only way I can see to chage the respect settings, is to use the #use rs232.

The problem Im having to being able to change, in and out, of different settings.

This is what I have tried so far..
Any help would ge great!

Note: I also tried putting the #use outside each function...no workie..


Code:
void   test_set_b()
{
#use delay(clock=10000000)
#use rs232(baud=115200,PARITY=E,BITS=8,STOP=1,xmit=PIN_C6, rcv=PIN_C7,ENABLE = PIN_A5,stream=COMM_PORT1,errors)
//#use rs232(baud=115200,PARITY=N, BITS=8,xmit=PIN_C6,rcv=PIN_C7,ENABLE = PIN_A5,stream=COMM_PORT1,errors)
#use rs232(baud=115200,PARITY=N, BITS=8,xmit=PIN_G1,rcv=PIN_G2,ENABLE = PIN_F7, stream=COMM_PORT2,errors)

   fprintf(COMM_PORT2,"RTS HIGH (NOT ACTIVE)PARITY=O, BITS=8,STOP=1\n\r");
   delay_ms(1);
               // Set Baud Rate to the user selected Baud rate.
}


void test_set_a()
{
#use delay(clock=10000000)
#use rs232(baud=115200,PARITY=N,BITS=8,STOP=1,xmit=PIN_C6, rcv=PIN_C7,ENABLE = PIN_A5,stream=COMM_PORT1,errors)
#use rs232(baud=115200,PARITY=N, BITS=8,xmit=PIN_G1,rcv=PIN_G2,ENABLE = PIN_F7,stream=COMM_PORT2,errors)
   fprintf(COMM_PORT2,"RTS LOW (ACIVE) baud=115200,PARITY=N, BITS=8\n\r");
                                 //Force baud rate to 115200 baud
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 21, 2008 8:43 pm     Reply with quote

This is in the forum archives. It's been discussed before, in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=26561
Got PIC



Joined: 21 Mar 2008
Posts: 10

View user's profile Send private message

PostPosted: Fri Mar 21, 2008 9:09 pm     Reply with quote

Maybe I should have mentioned..
#use rs232(baud=115200,PARITY=N, BITS=8,xmit=PIN_C6, rcv=PIN_C7,ENABLE = PIN_A5,stream=COMM_PORT1,errors)
//#use rs232(baud=115200,PARITY=O, BITS=8,STOP=2, xmit=PIN_C6, rcv=PIN_C7,ENABLE = PIN_A5,stream=COMM_PORT1,errors)
#use rs232(baud=115200,PARITY=N, BITS=8,xmit=PIN_G1,rcv=PIN_G2,ENABLE = PIN_F7, stream=COMM_PORT2,errors)

I'm using both uarts on this part...
Got PIC



Joined: 21 Mar 2008
Posts: 10

View user's profile Send private message

PostPosted: Fri Mar 21, 2008 10:25 pm     Reply with quote

PCM programmer;

I'm not sure if I can use you example if I'm already using the STREAM for both UARTS????


#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS, stream=No_Parity)
#use rs232(baud=9600,parity=O,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS, stream=Odd_Parity)
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