Hi ,
We are working KL27 series SOC . We are using LPUART module for one of peripehrial .
We need to implement the in the LPUART module in interrupt mode i.e. if some data arrived at the LPUART buffer ,
interrupt for LPUART will be raised .
We have done with adding the LPUART component with following configuration
a. Enabled the RX interrupt .
b. Enabled the RX callbacks with user buffer as "char bufferr[500]" .
c. Toggle the LED in the RX Callback .
Currently the RX callback is called for each byte . So if the peripheral is sending multiple data bytes we are receiving multiple interrupts .
Our expectation is to call the RX callback function when the data buffer is full i.e. if at least 500 bytes are received by LPUART .
We also checked the Component configuration in the KDS but there is no such configuration to set the buffer size for triggering the RX callback.
Hi, Anil,
Regarding your question, I suppose you use the KSDK2.0 for Kl27, if you use the LPUART_TransferReceiveNonBlockin() function, the LPUART uses interrupt mechanism to transfer data.
You can refer to the example:
C:\KSDK2.0_KL27\boards\frdmkl27z\driver_examples\lpuart\interrupt_transfer\kds
In the code, if you hope the callback() is called after 500 bytes have been received, you can change the example:
receiveXfer.data = g_rxBuffer;
receiveXfer.dataSize = 500; //ECHO_BUFFER_LENGTH; Rong modified
while (1)
{
/* If RX is idle and g_rxBuffer is empty, start to read data to g_rxBuffer. */
if ((!rxOnGoing) && rxBufferEmpty)
{
rxOnGoing = true;
LPUART_TransferReceiveNonBlocking(DEMO_LPUART, &g_lpuartHandle, &receiveXfer, NULL);
}
The receiveXfer.dataSize specifies the received number of bytes, after the number of bytes has been received, the callback function LPUART_UserCallback() is called.
Hope it can help you
BR
XiangJun Rong
Hi Thanks Rong for your inputs .
So you mean the system will receive interrupt for each byte receiption as the KL27 SOC contains only 1 byte ( 8-bit ) data register.
Is there any way to configure the LPUART to generate interrupt for every 500 bytes ( as our example ) of reception .
Thanks ,
Anil N.
Hi, Anil,
There are two mode for LPUART receiving:interrupt mode or polling mode, polling mode means that you poll a flag in LPUART status register which indicates if it has received byte, but the polling mode is inefficient. Interrupt mode means that an interrupt is invoked once the LPUART receives a byte, for the SDK, in the ISR, the code read the received data to memory, check if the predefined number of bytes has been received, if it has received the predefined number of bytes, the callback(0 function is called.
Hope it can help you.
BR
XiangJun Rong
Thanks XiangJun Rong for your inputs .
We moved from KDS 1.X to KSDK 2.0 version and using FreeRTOS LPUART driver APIs. But with the FreeRTOS LPUART driver I am getting below error .
Debug/../drivers/freertos_drivers/fsl_lpuart_freertos.c:62: undefined reference to `xTimerPendFunctionCallFromISR'
It seems to be issue in the FreeRTOS function not avaliable within the KSDK 2.0 .I have seen the configuration but no settngs for the same.
Please let me know how we can add this API in the FreeRTOS OS supported within the KSDK V 2.0.
Thanks ,
Anil N.
Hi, Anil,
I think you do not include header file, which includes the prototype which leads to the issue.
BR
XiangJun Rong