UART PROBLEM

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

cross mob
lock attach
Attachments are accessible only for community members.
BUTA_1301626
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

My RF module works with UART. I'm using TX UART for the transmitter side.

I would like to send [0x55,0x55,0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xAB, 0xBC, 0xCD] with the help of UART.

I use the program I added.

but I can't get the result I want. Where am I making a mistake?

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

Hi


Please try the attached program and check if it meets your requirement.

Thanks and regards

Harigovind

View solution in original post

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

What baud rate are you going to use?

As the UART_1 component says in its configuration utility tool, the baud rate is set to 2500bps.

GS004132.png

If you want to use 57600bps there are two solutions.

SOLUTION 1 :

Set the Clock_1 frequency to 57600*8=460,800Hz as follows.

GS004133.png

In this case, the actual baud rate becomes 57692bps

GS004134.png

SOLUTION 2 :

Configure the UART_1 component to use an internal baud rate clock.

GS004135.png

Then specify the expected baud rate.

GS004136.png

Regards,

Noriaki

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

Additional hint.

If you want to receive a character 0x00, use UART_1_GetByte() instead of UART_1_GetChar()

Regards,

Noriaki

0 Likes

It gives error when I use this code."UART_1_GetByte() "

.\ARM_GCC_541\Debug\main.o: In function `main':

C:\Users\TOSHIBA1\Desktop\UART_Tx01\UART_Tx01.cydsn/main.c:56: undefined reference to `UART_1_GetByte'

collect2.exe: error: ld returned 1 exit status

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

--------------- Build Failed: 06/18/2019 09:39:44 ---------------

0 Likes

Sorry, I was looking into the RX side project.

The UART TX has 4 bytes of FIFO as default.  When the FIFO is exhausted, the FIFO overwritten and unexpected TX output will be observed.

This is because the function UART_1_WriteTxData() does not block even if the FIFO is FULL.

SOLUTION 1 :

Check the FIFO status by the function UART_1_ReadTxStatus() before calling the UART_1_WriteTxData()

while (!(UART_1_ReadTxStatus() & UART_1_STS_FIFO_NOT_FULL));

UART_1_WriteTxData(0xAA);

while loops are required for all _WriteTxData() function.

SOLUTION 2 :

Use blocking function UART_1_PutChar() instead of UART_1_WriteTxData()

CPU waits until the FIFO is not FULL.

Regards,

Noriaki

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

It gives error when I use this code.

arm-none-eabi-gcc.exe -mcpu=cortex-m3 -mthumb -I. -IGenerated_Source\PSoC5 -Wa,-alh=.\ARM_GCC_541\Debug/main.lst -g -ffunction-sections -ffat-lto-objects -O0 -c main.c -o .\ARM_GCC_541\Debug\main.o

main.c: In function 'main':

main.c:56:35: error: 'UART_1_STS_FIFO_NOT_FULL' undeclared (first use in this function)

while  (! (UART_1_ReadTxStatus()& UART_1_STS_FIFO_NOT_FULL));

                                  ^

main.c:56:35: note: each undeclared identifier is reported only once for each function it appears in

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

--------------- Build Failed: 06/18/2019 10:36:17 ---------------

Which one do I need to choose in this window?

TX on TX complate

TXon FIFO EMPTY

TXon FIFO FULL

TXon FIFO NOT FULL

0 Likes

I am very sorry.

It's a TYPO. "_TX" is missing.

while (!(UART_1_ReadTxStatus() & UART_1_TX_STS_FIFO_NOT_FULL)) ;

UART_1_WriteTxData(0xAA); 

Regards,

Noriaki

0 Likes

I think there's a mistake.

Ekran Alıntısı1.JPG

The correct logical output should be as follows.

Ekran Alıntısı2.JPG

I can't find where the error is.

0 Likes

As the UART protocol, each byte is consisting of START BIT, DATA BITS, and STOP BITS as the "TX" signal of the following figure from the UART datasheet.

GS004139.png

If you don't want to have START BIT and STOP BITS, Shift Register may be used.

Please refer the "Shift Register" component.

Regards,

Noriaki

0 Likes

I don't want to use start and stop bits. How do I use Shift Register where.

Can you help with this?

Regards,

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

I have created a project using a Shift Register.

Please note that I didn't debug by oscilloscope.  I just confirmed the P1.6 as DC output.

Regards,

Noriaki

0 Likes

Ekran Alıntısı2.JPG

I think there's a mistake somewhere. It doesn't look like we want results.

Regards,

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

Hi


Please try the attached program and check if it meets your requirement.

Thanks and regards

Harigovind

0 Likes

Ekran Alıntısı1.JPG

When I use UART_1_PutChar () it changed as in the figure.

0 Likes

I tried them all separately. but the result is the same.

0 Likes