Problem when changing UART baud rate in run time

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

cross mob
Anonymous
Not applicable

Hi every body,

   

I'm doing a project with CY8C24123A, PSoC designer 5.4, using user modules: UART, Counter8 (determine working frequency for UART).

   

Contents:

   

- PSoC receive data from another circuit (P0.4 RX)

   

-Then, PSoC send data to PC via RS232 circuit (P0.5 TX)

   

-When receiving data, baud rate is 4800; when sending data, buad rate is 9600

   

If I don't change baud rate (4800) when PSoC running, PSoC works well (receive or send data OK, I can check data on PC, I'm using Terminal 1.9b).

   

If I change baud rate when PSoC running,  PSoC can't work as I want. No data on the PC! At forum, I knew that I can change UART baud rate in run time of PSoC. 

   

Can you check my project, please? Have you another solutions? Please tell me!

   

Many thnanks!

0 Likes
14 Replies
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Below is my project!

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

A different solution which is easier to test would be

   

us an RX8 and a TX8 module and two Counte8 with appropiate dividers. You do not need to set the compare-value and you can check out each channel separately. But this uses more resources.

   

Did you successfully send data to PC with the higher baud rate (9600)?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I have a project that I usa speed change on the fly as well. The one thing I do in my project that you are not doing is stop the UART before you change the counter, then restart the UART. See if that helps

   

 

   

Mike

0 Likes
Anonymous
Not applicable

 Hi Bob, MikeP

   

@Bob: If I don't change baud rate when PSoC running, baud rate is constant. I can send data to PC well with higher baud rate with another project.  I'll try to use TX8, RX8 module!

   

@MikeP: I'll check code. I'll do that you advise!

   

Many thanks.

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

You could possibly eliminate the need for counters, just use register writes

   

for the VC3 clock divider register. Look at TRM for register name, and follow

   

recomendations, like stopping clock before you do write. You might also consider

   

Rx interrupt to catch baud change character, to turn around UART settings fast.

   

 

   

Regards, Dana.

   

 

   

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Register pic did not post, now attached.

0 Likes
Anonymous
Not applicable

 Hi Dana,

   

I'll do soluiton that you said.

   

@Bob : if using TX8 and RX8, it is OK. PSoC running well as I want.

   

Many thanks!

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

Great!

   

I have a suggestion concerning the IO-pins you use: As you can see the port0 pins are the only ones connected to the analog parts of the chip. So when you save them (for future use) and take port1 pins for digital IO you may use the same design for different purposes.

   

 

   

Bob

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

If you decide to use interrupts, consider C interrupt, heres how to

   

implement one -

   

 

   

    

   

          http://www.cypress.com/?id=4&rID=36720

   

    

   

          http://www.planetpsoc.com/component/content/article/43-writing-a-c-isr.html

   

    

   

          http://www.planetpsoc.com/psoc1-articles-digital/13-basics-of-psoc-gpio.html?start=7

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Dana, Bob, MikeP

   

Thank you so much for your help!

   

After using RX8, TX8, PSoC run well as I want (solution of Bob).

   

I'm doing solution: UART, Counter8 ( @MikeP). But PSoC can't work well, no data on the PC.

   

Can you please check code for me? Is it correct? I modified code which MikeP advise :"stop the UART before you change the counter, then restart the UART".

   

@MikeP: Can you send your project which you did successfully for me, please?

   

Below is my project which I modified (UART, Counter8).

   

Many thanks!

0 Likes
Anonymous
Not applicable

 Hi Dana, Bob, MikeP

   

Can you check my project which I uploaded (UART_ChangeBaudRate_260614.zip), please?

   

I want try code for solution "using UART and Counter to change baud rate while PSoC running".

   

Many thanks!

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

When you are verifying this against PC, you realize the PC does not auto negotiate

   

to the new baud rate ? It stays at whatever the initial connection was made at. Unless

   

you have a custom  win application.

   

 

   

Regards, Dana.

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

On line 31 you write to PC with 4800 bd. on line 53 you change the rate to 9600bd and send out data to PC on line 64.

   

But either the first write to PC or the second will go amiss, since the PC does never change its defined baud-rate by itself.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Dana, Bob

   

Thanks for your supports!

0 Likes