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

PSoC™ 6 Forum Discussions

notAnumber
Level 1
Level 1
5 replies posted 25 sign-ins 10 sign-ins

Hello,

I am trying to create a communication over UART using a PSOC 6.

On the transmit side I am sending an array using the Cy_SCB_UART_PutArrayBlocking();

On the receiver side I want to retrieve the bytes one by one and add them into a buffer array.

This should be done in the ISR function. But after receiving all the bytes and Cy_SCB_UART_Get returns Cy_SCB_UART_RX_NO_DATA. It gets stucked in the ISR. 

It's like the array that has been transmitted is infinitely long. 

My ISR

void ISR()
{

uint32_t data;

int index = 0;
data = Cy_SCB_UART_GET(UART_HW);
while(data != CY_SCB_UART_RX_NO_DATA)
{
buffer[index] = data;
index++;
data = Cy_SCB_UART_GET(UART_HW);
}

 

The buffer gets filled up with the data, as it should. But after that it gets stucked lopping CY_SCB_UART_RX_NO_DATA.

 

What do you think could be wrong?

0 Likes
2 Replies
pblemel
Level 3
Level 3
First like received 5 questions asked 10 replies posted

Hello,

You wrote

After receiving all the bytes and Cy_SCB_UART_Get returns Cy_SCB_UART_RX_NO_DATA. It gets stucked in the ISR. 

I understand this to mean that 1) you have received all of the bytes and 2) you have received CY_SCB_UART_RX_NO_DATA, which should terminate the loop.

What happens next isn't clear from your question. You wrote

But after that it gets stucked lopping CY_SCB_UART_RX_NO_DATA.

It is not clear to me what this means given that you have confirmed that you received CY_SCB_UART_RX_NO_DATA (in the debugger, I presume).  Are you saying that the loop

 

while(data != CY_SCB_UART_RX_NO_DATA)

 

does not exit when data == CY_SCB_UART_RX_NO_DATA?

If so, then my first guess would be that you are corrupting/over-writing memory when appending to the buffer.  Is it large enough to accept the entire transmission? 

What do you see if you read the RX status register after reading your last byte?

Edited to add that, personally, I would suggest not writing a serial ISR this way.  One issue (not related to your question) is that you have created a race condition between reading a byte from the FIFO and receiving the next byte. 

I don't know your use case, but the PDL provides a few different ways to accomplish what you want to do more reliably.  For example :

uint8_t rxBuffer[BUFFER_SIZE];
/* Start receive operation (do not check status) */
(void) Cy_SCB_UART_Receive(SCB1, rxBuffer, sizeof(rxBuffer), &uartContext);
/* Blocking wait until buffer is full */
while (0UL != (CY_SCB_UART_RECEIVE_ACTIVE & Cy_SCB_UART_GetReceiveStatus(SCB1, &uartContext)))
{
}

could be modified to include some error checking.

 

 

Thank you for you response.

I apologize if my previous message was unclear. 

The loop functions as expected and fills the buffer with the correct data.

However, the ISR function continues to be called after the loop finishes. The return value from Cy_SCB_UART_Get() is 4294967295, which I understand to be CY_SCB_UART_RX_NO_DATA. 

Cy_SCB_UART_GetRxFifoStatus() returns 69, the meaning of which I am unable to determine. 

I expect that the ISR should not be triggered once all the data has been sent and processed, but in my case it continues to be called.

0 Likes