AnsweredAssumed Answered

S32K146 Rx data missing when Tx Send Data Function be called too frequently

Question asked by Xiaoyu Zhao on Mar 18, 2019
Latest reply on Mar 20, 2019 by Daniel Martynek

Hi expert,

I'm using S32K146 EVB to implement uart Rx and Tx data transfer.

I use LPUART in DMA mode both on Rx and Tx. I set BaudRate to 115200.

When I called LPUART_DRV_SendData too frequently(10ms periodly),I found that my Rx

Data Missing.

My code listed below:
#define MD_REC_QUEUE_LEN (100)

/* The rx data if from a periphal modem device connected to S32K146 through uart*/
rx_callback(void *driverState, uart_event event, void* userData)
{
(void)driverState;
(void)userData;

if(UART_EVENT_RX_FULL == event)
{
MdRxHandler(rxBuffer);
LPUART_DRV_SetRxBuffer(INST_LPUART2, rxBuffer);

}else if(UART_EVENT_ERROR == event) //Error event handle: to reset rx receive data.
{
LPUART_DRV_AbortReceivingData((INST_LPUART2);
LPUART_DRV_ReceiveData(INST_LPUART2, rxBuffer, sizeof(rxBuffer));
}
}

void ModemInit() //uart init and fisrt receive data
{
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = ODD parity
- BaudRate = 115200 baud
- Hardware flow control disabled (RTS and CTS signals) */
LPUART_DRV_Init(INST_LPUART2, &lpuart2_State, &lpuart2_InitConfig0);
EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0,
edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);
LPUART_DRV_InstallRxCallback(INST_LPUART2, rxCallback, NULL);
LPUART_DRV_ReceiveData(INST_LPUART2, rxBuffer, sizeof(rxBuffer));
}

void MdRxHandler(uint8_t* data)
{
ReqInfo reqMsg;
memset(&reqMsg,0x00,sizeof(ReqInfo));
reqMsg.msgId = MD_CMD_RX;
memcpy(reqMsg.rxdata, data, MAX_RX_MSG_SIZE );
xQueueSendFromISR(MdRecQueue, (void*)&reqMsg, NULL);
}

void MdTxHandler(uint8_t* data, uint16_t length)
{
ReqInfo reqMsg;
memset(&reqMsg,0x00,sizeof(ReqInfo));
reqMsg.msgId = MD_CMD_TX;
reqMsg.txLen = length;
memcpy(reqMsg.txdata, data, length);
xQueueSend(MdRecQueue, (void*)&reqMsg, (TickType_t)0);
}

ModemTask()
{
MdTimerCreate(); //create a 10ms Timer Loopback for Tx data.

ReqInfo reqMsg;
memset(&reqMsg,0x00,sizeof(ReqInfo));
while(1)
{
xQueueReceive(MdRecQueue, (void *)&reqMsg, 100);

switch(reqMsg.Id)
{
case MD_CMD_RX:
{
XXXXXXXXXXX //this branch can not be enter when TX Loopback too frequently.
}
case MD_CMD_TX:
{
LPUART_DRV_SendData((INST_LPUART2, data, length);
break;
}
defalut:
break;

}

}
}
void MdTimerLoopBack(xTimerHandle pTimer) //10ms peroidly Timer Trigger
{
uint8_t txData[100] = "xxxxxx";
while(1)
{
if( STATUS_SUCCESS== LPUART_DRV_GetTransmitStatus(INST_LPUART2, &byteRemaining))
{
MdTxHandler(txData, sizeof(txData));
break;

}
}
}

Outcomes