Hi Everyone;
I am trying to communicate with Uart. But I am encountering such an error. What could be the reason for this?
I see the same error when I activate FIFO Support. The difference between activating and not activating FIFO Support is that when FIFO Support is active, the error occurs after a while. What does FIFO Support do?
Thank you in advance.
Regards.guurii
Hi guurii,
Thanks for reaching out Renesas Engineering Community.
For the error message shown in your screenshot, it might because that you don't include the library file of these functions.
You should include the *.h file at the file that you use these functions.
Hope it helps,
NP_Renesas
I think I included the necessary library files. I don't get any error messages. It is not possible for me to communicate only via uart. My code keeps flowing. What does FIFO Support do?
If you have included the library file correct, please check that you have declared the functions in library file.
And the FIFO support will let you get a callback immediately when each byte is received. Or if you set "Receive FIFO Trigger Leve" to max, you will get a callback when FIFO is full or after 15 bit times with no data (fewer interrupts).
For more information about uart FIFO, please check this document:
RA Flexible Software Package Documentation: UART (r_sci_uart) (renesas.github.io)
I still keep getting the OVERFLOW error.
I use circular buffer. I read with the
What could be the reasons why I am getting this error? Do you have any ideas?
Thanks.
Can you share your code where you call R_SCI_UART_Read ? It could be possible that you do not wait until the receive operation is completed before you receive new data.
Hi,
The code I want to write is like below.What should I do to wait for the receive operation is complete before receive new data?
#define UART1_RECEIVEBUFFERSIZE 100 static unsigned char uart1_Receivechar = 100; static unsigned char uart1_Transmitchar = 100; static unsigned char Uart1ReceiveBuffer[UART1_RECEIVEBUFFERSIZE]; static unsigned char Uart1ReceiveCounter = 0U; unsigned char uartByte; void user_uart_callback(uart_callback_args_t *p_args) { /* Handle the UART event */ switch (p_args->event) { /* Received a character */ case UART_EVENT_RX_CHAR: { break; } /* Receive complete */ case UART_EVENT_RX_COMPLETE: { ata_Uart1_ReceiveInterrupt(); break; } /* Transmit complete */ case UART_EVENT_TX_COMPLETE: { ata_Uart1_TransmitInterruptEnd(); break; } default: { } } } static void Uart1ByteReceived(unsigned char uartByte) { if (Uart1ReceiveCounter < UART1_RECEIVEBUFFERSIZE) { Uart1ReceiveBuffer[Uart1ReceiveCounter++] = uartByte; } else { Uart1ReceiveCounter = 0U; trk_PushMessage1msNullUserData(&CheckUartReceiveBufferThread); } } void Uart1ReceiveInterrupt(unsigned char Received_Byte) { Uart1ByteReceived(Received_Byte); } unsigned long CheckUartReceiveBufferThread(void *user_data) { unsigned char ReceiveCounter; unsigned char ReceiveCounterControl = 0U; if (Uart1ReceiveCounter != 0U) { ReceiveCounterControl = Uart1ReceiveCounter; for (ReceiveCounter = 0U; ReceiveCounter < ReceiveCounterControl; ReceiveCounter++) { ata_commcallback(Uart1ReceiveBuffer[ReceiveCounter]); } if (ReceiveCounterControl == Uart1ReceiveCounter) { Uart1ReceiveCounter = 0U; } else { for (ReceiveCounter = 0U; ReceiveCounter < (Uart1ReceiveCounter - ReceiveCounterControl); ReceiveCounter++) { Uart1ReceiveBuffer[ReceiveCounter] = Uart1ReceiveBuffer[ReceiveCounterControl + ReceiveCounter]; } if (Uart1ReceiveCounter >= ReceiveCounterControl) { Uart1ReceiveCounter = (Uart1ReceiveCounter - ReceiveCounterControl); } } } return (unsigned long)msg_ProcessAfter1ms * 10U; } void ata_Uart1_ReceiveInterrupt(void) { Uart1ReceiveInterrupt(uart1_Receivechar); R_SCI_UART_Read(&g_uart0_ctrl, (uint8_t *)&uart1_Receivechar, 1); }
You can add a delay at RX_COMPLETE to wait your process done.
I think you're right. I put a breakpoint in r_sci_uart_c where r_sci_uart_call_callback is and when I debugged I saw that the buffer filled without any problems.
I will follow your advice.
Thanks for be interested.
I added delay but still the problem was not solved. Anyone have an idea?
Hi guurii. There are 2 interrupt events when it comes to reads.
UART_EVENT_RX_CHAR // Fires after "every" character... this is the most common
UART_EVENT_RX_COMPLETE // Fires ONLY when the amount of data specified in the read is received
Most applications using UART are connected to some sort of HMI, like a terminal, and receive 1 character at a time and use the first interrupt UART_EVENT_RX_CHAR to "accumulate" the result. If it is a machine talking to a machine and you "know" that x amount of data is to be received, like a packet, then you would use the RX_COMPLETE interrupt. HOWEVER, your code will have to do data-alignment on the packet and handle dropped characters and so on, so I would expect error recovery and alignment code (like looking for a SOP character or something.
I suspect, your application is expecting one character at a time, in which case you want to use the UART_EVENT_RX_CHAR interrupt. You can still set the buffer length in the READ call to something other than 1.
Your error likely stems from the fact when you do your follow-on READ you are specifying a length of 1. You should always specify a length of whatever the buffer length is...something greater than 1, if you intend to do a "packet" type of interface.