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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,781 Views
317336284
Contributor I

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;

}
}
}

Labels (1)
Tags (1)
0 Kudos
4 Replies

1,335 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Do you see the RX data from the modem on the bus using a logic analyzer?

Is there any error reported?

pastedImage_1.png

Thanks,

Daniel

0 Kudos

1,335 Views
wjandsq
Contributor IV

static void LPUART0_Rx_Callback_IRQHandler(void *driverState, uart_event_t event, void *userData) {

lpuart_state_t * s_lpuartStatePtr = (lpuart_state_t *)driverState;

....
if (event == UART_EVENT_ERROR) {

    ...... must

     LPUART_DRV_ReceiveData(INST_LPUART0, UART0_Rx_Buf, UART0_Rx_Buf_Size);
} else if (event == UART_EVENT_DMA_IDLE) {

    ......

    LPUART_DRV_ReceiveData(INST_LPUART0, UART0_Rx_Buf, UART0_Rx_Buf_Size);

} else if (event == UART_EVENT_RX_FULL) {

    ......

    LPUART_DRV_SetRxBuffer(INST_LPUART0, UART0_Rx_Buf, UART0_Rx_Buf_Size);

} else if (event == UART_EVENT_END_TRANSFER) {

    ......

    LPUART_DRV_ReceiveData(INST_LPUART0, UART0_Rx_Buf, UART0_Rx_Buf_Size);

}

}

1,335 Views
2571997326
Contributor I

Hi,

  I look at the code and the manual and I don't know how to understand UART_EVENT_END_TRANSFER event,

  May I ask how to correctly understand the meaning of UART_EVENT_END_TRANSFER ?

And , when does the UART_EVENT_END_TRANSFER event occur?

Thanks !

0 Kudos

1,335 Views
wjandsq
Contributor IV

LPUART_DRV_SetRxBuffer   have  no  setting,  then the UART_EVENT_END_TRANSFER event  will  happen

0 Kudos