Two UARTs and two buffer over 8 bytes - one of them not works ok

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

cross mob
WiWi_4415241
Level 1
Level 1
5 sign-ins Welcome! First question asked

Hi all,

I am new in community and its my first question about PsoC4 - forgive me mistakes . I'm working with CY8C4248LQI-BL583 from Cy8ckit-042-BLE-A kit and i have problem with buffer when i use two separate UARTs.

So in details:

- I have two UART blocks (say UART_1 and UART_2) both are configured with buffer Rx and Tx 128 bytes.

- UART_1 baud is 115200;

- UART_2 baud is 460400 (used external clock generated by cy_clock)

- UART_1 nad UART_2 buffers are read in program without interrupt (main function)

- from UART_1 and UART_2 i want read data from buffer;

- UART_1 works ok (received data are stored in circular buffer up to 128 bytes)

- UART_2 not work ok (received data are stored in circular buffer up to 8 bytes - should be 128 as configured)

Now my question is that why second UART is not working ok like UART_1 ? Should i configure something special for it when i need to use two separate circular buffer ? or it's bug in Creator ?

I have no idea how resolve problem (of coursce i can try write own circular buffer for both UARTs i think,  but why Creator works only with one UART)

With best regards

Wiktor

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello WiWi_4415241

I have attached a similar project with 2 uarts. This was found to be working at my end. Please try this and let us know the result.

Thanks and regardsHarigovind

View solution in original post

0 Likes
6 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

I don't know if this is a root cause.

You said the UART_2 uses an external clock generated by a cy_clock component.

What is the frequency of the external clock?

What is the oversampling rate of UART_2?

GS004445.png

When UART_2 is configured as x12 oversampling rate and 460400bps baud rate, a warning appears saying "UART Tolerance exceeds recommended maximum of 2.5%"  This means the UART interface may not be used for that baud rate.

GS004446.png

Please try to change the oversampling rate to 8 for a better baud rate.

0 Likes

I'm sorry for mistake - UART_2 baud should be 460800 (not 460400 as i write before).

In top design it looks:

pastedImage_0.png

Settings of UartCLK as external clock for UART_2:

pastedImage_2.png

And UART_2 configuration:

pastedImage_1.png

It's not exacly 460800bps but still is in tolerance.


One thing - when in project is only one UART_2 use it works with buffer ok. But problem occure when i add UART_1 with that same parameters with 115200 baud.

I will try change oversampling and see what will be the effect.

0 Likes

Nothing change. Still that same problem - not used 128 bytes buffer but one thing is change. Not 8 bytes are stored but 9 (used SpiUartGetRxBufferSize() function).


Additional i see that second read byte is Null but should be "O" - 0x4F. In both situation is that same.

0 Likes

It seems that the software buffer takes long time.  Can you try to use a DMA at the RX part of the UART_2?

There is a code example "DMA_UART_PSoC4" using UART with DMA.

0 Likes
lock attach
Attachments are accessible only for community members.
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello WiWi_4415241

I have attached a similar project with 2 uarts. This was found to be working at my end. Please try this and let us know the result.

Thanks and regardsHarigovind

0 Likes

Hello again, I am sorry for disappear for few days - short holidays.

Thank you AH_96​ for sample. It looks like it solves my problem. I have no idea why in my configuration it was not working. Anyway i will use your code and adapt it to my project. let's see if it works


Thank you all for help.

0 Likes