Hello i'm using Uart communication in s32k144 in interrupt mode with the sdk generated by Processor Expert. I'm trying to use the Callback function for receiving data and send data continuously in while loop. The code stops transmitting after 4 bytes and niether does it receives. Code snippet below:
void ThisIsMyRXCallback(void *driverState, uart_event_t event, void *userData)
{
PINS_DRV_TogglePins(PTD,(LED15));
}
int main(void)
{
CLOCK_SYS_Init(g_clockManConfigsArr,CLOCK_MANAGER_CONFIG_CNT,g_clockManCallbacksArr,CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
INT_SYS_InstallHandler(LPIT0_Ch0_IRQn,&LPIT_ISR,(isr_t *)0);
LPUART_DRV_Init(INST_LPUART1, &lpuart1_State, &lpuart1_InitConfig0);
LPUART_DRV_ReceiveData(INST_LPUART1,(uint8_t *)&datas,1);
LPUART_DRV_InstallRxCallback(INST_LPUART1,ThisIsMyRXCallback,NULL);
LPIT_DRV_Init(INST_LPIT1, &lpit1_InitConfig);
LPIT_DRV_InitChannel(INST_LPIT1, 0, &lpit1_ChnConfig0);
LPIT_DRV_StartTimerChannels(INST_LPIT1,(1<<0));
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS,g_pin_mux_InitConfigArr);
PINS_DRV_SetPinsDirection(PTD,(LED15));
PINS_DRV_SetPins(PTD,LED15);
/* For example: for(;;) { } */
for(;;)
{
uint8_t data[20] = "Hello World\r\n";
LPUART_DRV_SendData(INST_LPUART1,(const uint8_t *)&data,strlen(data));
Delay(500);
}
}
I was able to solve this issue by using the code below.
status = UART_Init(&lpuart1_uart_instance, &lpuart1_uart_Config0);
// After calling UART_Init, you need to tell the driver to listen for a single byte
status = UART_ReceiveData(&lpuart1_uart_instance, &g_rx_byte, 1);
At the interrupt service routine.....
void on_byte_received(void *driverState, uart_event_t event, void *userData)
{
if(event == UART_EVENT_RX_FULL)
{
packet_decoder(g_rx_byte);
// After you got the byte, tell the driver to listen for more bytes. Dont use the UART_ReceiveData.
// Use UART_SetRxBuffer insted.
UART_SetRxBuffer(&lpuart1_uart_instance, &g_rx_byte, 1);
}
}
Sorry for the late reply
HI, I have the same problem. How did you resolve it? Because there is the bug in the driver.