PSoC5LP : UART API Difference between _GetChar() and _GetReadData()

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

cross mob
MiNe_85951
Level 7
Level 7
Distributor - TED (Japan)
50 likes received 500 replies posted 50 solutions authored

Hi,

We use the UART component of PSoC5LP.

The UART component has "UARTRX-On Byte Received" enabled.
Interrupt is generated by receiving byte data,
The following processing is performed in the interrupt.

/* UART Rx interrupt routine */

while ((UART_1_ReadRxStatus() & UART_1_RX_STS_FIFO_NOTEMPTY) !=0) {

uint8 data = UART_1_GetChar();

}

In this process, data cannot be obtained normally by the _GetChar() API.

However, it can be received normally if modified as follows.

/* UART Rx interrupt routine */

while ((UART_1_ReadRxStatus() & UART_1_RX_STS_FIFO_NOTEMPTY) !=0) {

uint8 data = UART_1_GetReadRxData(); // Change API

}

In this case,
What is the difference between Get_Char function and ReadRxData function?

I confirm for the contents of each API,
The GetChar function checks the status flag, and the ReadRxData function does not check the status flag.

I think the difference is only checking the status flag.
Does this difference affect the behavior?

Regards,

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

MaMi,

The issue you are seeing is that GetChar() is primarily designed to be used in a Rx polling strategy.

If you want to use GetChar() try getting rid of your API call to ReadRxStatus().  Since GetChar() reads the RxStatus register, at a minimum it is redundant to your ReadRxStatus() call.

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

MaMi,

The issue you are seeing is that GetChar() is primarily designed to be used in a Rx polling strategy.

If you want to use GetChar() try getting rid of your API call to ReadRxStatus().  Since GetChar() reads the RxStatus register, at a minimum it is redundant to your ReadRxStatus() call.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
MiNe_85951
Level 7
Level 7
Distributor - TED (Japan)
50 likes received 500 replies posted 50 solutions authored

Len-san,

Thank you for your reply.

We understaoo that redundancy is a problem.

We take care not to use CetChar() and ReadRxData() of API the same way.

Regards,

0 Likes