change parity in a UART

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hello

I Want to know if is possible change the parity in a uart module in when the code is in execution, I made this code

   

........

   

while(1){

   

                 TX8_Start(0x02);

   

TX8_PutSHexByte(0x08);

   

TX8_Start(0x00);

   

TX8_PutSHexByte(0x03); 

   

                .............

   

}

Can I change the parity with this manner?

0 Likes
17 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I personally would issue a TX8_Stop() in between to shut down the UART. Your example should work, but I didn't go through the generated code yet. Do you have got a PSoC1 Development Kit to proof-read with a logic-analyzer?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

It would be safer to check and make sure the previous byte was completly shifted out before you do anything with the UM. 

0 Likes
Anonymous
Not applicable

 Hello!

unfortunately I don´t  have a PSoC1 Development Kit, but I will prove TX8_Stop() and see what happen 🙂

0 Likes
Anonymous
Not applicable

 Hello HL

I proved using TX8_Stop() function sending the data to hyperterminal by Bluetooth but I don't receive any data this is the code that I have used 
 

   

TX8_Start(0x02);

   

TX8_PutSHexByte(0x08);

   

TX8_Stop();

   

 

   

TX8_Start(0x00);

   

LCD_Delay50uTimes(248);

   

TX8_PutSHexByte(0x08);

   

TX8_Stop();

When I use the code that I wrote before, I received the data that I sent but I don't know if the parity really change.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You are not using BYTE UART_bReadTxStatus(void)

   

 

   

To test if first put was finished before you stopped UART. So

   

your first 2 byte xmit may have been prematurely terminated.

   

As HL mentioned earlier.

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You are not using BYTE UART_bReadTxStatus(void)

   

 

   

To test if first put was finished before you stopped UART. So

   

your first 2 byte xmit may have been prematurely terminated.

   

As HL mentioned earlier.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Thanks dana

It's correct this code
 

   

                TX8_Start(0x02);

   

TX8_PutSHexByte(0x08);

   

while( !( TX8_bReadTxStatus() & TX8_TX_BUFFER_EMPTY ) );

   

TX8_Stop();

   

 

   

TX8_Start(0x00);

   

LCD_Delay50uTimes(248);

   

TX8_PutSHexByte(0x08);

   

while( !( TX8_bReadTxStatus() & TX8_TX_BUFFER_EMPTY ) );

   

TX8_Stop();

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you look into the datasheet of the TX8 you will see that there is a TX-Buffer and a Shift register. Data is transferred from the Buffer to the shifter which frees the buffer again, but nothing has been shifted out yet. When the shifter is ready, it is signalled by the TX8_TX_COMPLETE bit set in the status. So, to make a long story short: You ought to monitor the TX_COMPLETE.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 So I only change TX8_TX_BUFFER_EMPTY for TX8_TX_COMPLETE  in the code that I put Before?
Thanks 🙂

0 Likes
Anonymous
Not applicable

 If i am using the buffer, i would check buffer empty first and then tx complete. Or check both in one instruction.

0 Likes
Anonymous
Not applicable

I proved Using TX8_TX_BUFFER_EMPTY and then TX8_TX_COMPLETE but I recieved the data incompletely, I send 0xA8 and 0xC8 with the TX8_PutSHexByte but only recieved  8 (the Byte A is missing) and then C8 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Manual states that reading the status-bits will clear them! So if you do not intermediately keep the result from the status-read you might clear a "transfer complete" when looking for a "buffer empty".

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Finally found this thread, my own one  http://www.cypress.com/?app=forum&id=2233&rID=56771

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Bob, your thread you referred to should be looked at by Cypress

   

to create/incorporate an API to make this bulletproof for users in

   

a future Designer release.

   

 

   

Just a thought.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Dana,

   

tell to Robyn, she'll take care of.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Hello

My problem was resolved,I used the TX_Complete and TX_BUFFER_EMPTY and use the function SendData and work perfect Thanks for your help 🙂

0 Likes
Anonymous
Not applicable

glad to here that

0 Likes