S32K1xx Lpuart IDLE detected with DMA transfer

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

S32K1xx Lpuart IDLE detected with DMA transfer

S32K1xx Lpuart IDLE detected with DMA transfer

What is S32K1‘s IDLE feature:

IDLE is set when the LPUART receive line becomes idle for a full character time after a period of activity.When CTRL[ILT] is cleared, the receiver starts counting idle bit times after the start bit.

Why write this demo?

Because the RTM driver does not support Lpuart's IDLE detect.

What needs to be modified?

-1.add "UART_EVENT_DMA_IDLE = 0x04U" to “callbacks.h”

Senlent_0-1725257766096.png

 

-2 add "LPUART_DRV_RxIdleCallback" to ".lpuart_driver.c"

Senlent_1-1725257909301.png
 
-3 Define “LPUART_DRV_RxIdleCallback” function
 
static void LPUART_DRV_RxIdleCallback(uint32_t instance)
{
	DEV_ASSERT(instance < LPUART_INSTANCE_COUNT);

	LPUART_Type *base = s_lpuartBase[instance];

	lpuart_state_t * lpuartState = (lpuart_state_t *)s_lpuartStatePtr[instance];

	LPUART_ClearStatusFlag(base,LPUART_IDLE_LINE_DETECT);

	if(lpuartState->transferType == LPUART_USING_DMA)
	{
		lpuartState->rxSize = EDMA_DRV_GetRemainingMajorIterationsCount(lpuartState->rxDMAChannel);

		LPUART_DRV_StopRxDma(instance);

		lpuartState->rxCallback(lpuartState,UART_EVENT_DMA_IDLE,NULL);/*UART_EVENT_DMA_IDLE : 0x04*/
	}
}
 
Senlent_3-1725258145125.png

 

-4 add below code to "LPUART_DRV_IRQHandler" and be sure these code must  be put before "LPUART_DRV_ErrIrqHandler(instance)"

    /* Handle idle line interrupt */
    if (LPUART_GetIntMode(base, LPUART_INT_IDLE_LINE))
    {
        if (LPUART_GetStatusFlag(base, LPUART_IDLE_LINE_DETECT))
        {
            LPUART_DRV_RxIdleCallback(instance);
        }
    }
Senlent_2-1725257994099.png

 

-5 configure IDLE releated register in main function.

  LPUART1->CTRL |= LPUART_CTRL_ILT(1); 
  LPUART1->CTRL |= LPUART_CTRL_IDLECFG(7); 
  LPUART1->CTRL |= LPUART_CTRL_ILIE(1); 
Senlent_4-1725258763381.png

 

Test environment:

Hardware is base on S32K144EVB-Q100

Software is S32 Design Studio for Arm V 2.2 + RTM 3.0.X

Demo Description:

          The baud rate of the serial port is set to 19200, and the function implemented is to send back the received data using DMA methods

.

 

 

 

Attachments
No ratings
Version history
Last update:
‎09-01-2024 11:51 PM
Updated by: