S32K1xx LPUART IntCtrl_IP callback function Implement

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K1xx LPUART IntCtrl_IP callback function Implement

ソリューションへジャンプ
1,556件の閲覧回数
Pohsuan
Contributor III

Hello NXP Team,

I'm modifying the UART example from S32K1 AUTOSAR R21-11 RTD 2.0.0 P04 D2404 Example Project and want to add a UART RX interrupt callback function.

Currently, I'm using IntCtrl_IP to add the callback function, but it's not working.

UART_IntCTRL_IP.png

Here is my LPUART0_ISR function

void LPUART0_ISR()
{
    const char* pBuffer = "LPUART0_ISR\r\n";
    volatile Lpuart_Uart_Ip_StatusType lpuartStatus = LPUART_UART_IP_STATUS_ERROR;
    uint32 T_timeout = 0xFFFFFF;
    uint32 remainingBytes;
 
    Lpuart_Uart_Ip_AsyncSend(UART_LPUART_INTERNAL_CHANNEL, pBuffer, strlen(pBuffer));
    /* Check for no on-going transmission */
    do
    {
        lpuartStatus = Lpuart_Uart_Ip_GetTransmitStatus(UART_LPUART_INTERNAL_CHANNEL, &remainingBytes);
    } while (LPUART_UART_IP_STATUS_BUSY == lpuartStatus && 0 < T_timeout--);
}

 

 

Or is there any sample code I can refer to?

Thank you!

タグ(1)
0 件の賞賛
返信
1 解決策
1,542件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if you want to use driver's interrupt routine and call own callback from it then just configure respective handler in IntCtrl component (here lpuart 6 is shown, use your instance) and add your callback function in Lpuart component

2025-02-07_11-43-35.png2025-02-07_11-43-57.png

Then in your code you add callback and do your need according available events

void Uart_Callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
    if(HwInstance == UART_INSTANCE)
    {
    	switch(Event){
    	case LPUART_UART_IP_EVENT_RX_FULL:

    		break;
    	case LPUART_UART_IP_EVENT_TX_EMPTY:

    		break;
    	case LPUART_UART_IP_EVENT_END_TRANSFER:

    		break;
    	case LPUART_UART_IP_EVENT_ERROR:

    		break;
    	case LPUART_UART_IP_EVENT_IDLE_STATE:

    		break;
    	default:
    		break;
    	}
    }



}

 

BR, Petr

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
1,543件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if you want to use driver's interrupt routine and call own callback from it then just configure respective handler in IntCtrl component (here lpuart 6 is shown, use your instance) and add your callback function in Lpuart component

2025-02-07_11-43-35.png2025-02-07_11-43-57.png

Then in your code you add callback and do your need according available events

void Uart_Callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
    if(HwInstance == UART_INSTANCE)
    {
    	switch(Event){
    	case LPUART_UART_IP_EVENT_RX_FULL:

    		break;
    	case LPUART_UART_IP_EVENT_TX_EMPTY:

    		break;
    	case LPUART_UART_IP_EVENT_END_TRANSFER:

    		break;
    	case LPUART_UART_IP_EVENT_ERROR:

    		break;
    	case LPUART_UART_IP_EVENT_IDLE_STATE:

    		break;
    	default:
    		break;
    	}
    }



}

 

BR, Petr

0 件の賞賛
返信
1,483件の閲覧回数
Pohsuan
Contributor III

Hi PetrS

Thanks for your reply

I'm testing the UART callback function by enabling UART loopback mode.

I can receive the UART_Callback event, but the LPUART_UART_IP0_IRQHandler function is not being executed.

I have some questions regarding this setup:

1. Where can I set the LPUART_UART_IP_EVENT_RX_FULL value?

2. If the UART event is triggered, what is the purpose of the LPUART_UART_IP0_IRQHandler function?

3.If UART loopback mode is not enabled and I use another UART TX to send data to the S32K118 RX,

I am unable to receive the LPUART_UART_IP_EVENT_RX_FULL event.

here is my testing function

void sendstring(char* string)
{
    Lpuart_Uart_Ip_AsyncSend(UART_LPUART_INTERNAL_CHANNEL, string, strlen(string));
}

void UART_Callback(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
    if(HwInstance == UART_LPUART_INTERNAL_CHANNEL)
    {
    	switch(Event){
    	case LPUART_UART_IP_EVENT_RX_FULL:

    		sendstring("LPUART_UART_IP_EVENT_RX_FULL\r\n");
    	    ISR_UART = 1;

    		break;
    	case LPUART_UART_IP_EVENT_TX_EMPTY:
    		sendstring("LPUART_UART_IP_EVENT_TX_EMPTY\r\n");

    		break;
    	case LPUART_UART_IP_EVENT_END_TRANSFER:
    		//sendstring("LPUART_UART_IP_EVENT_END_TRANSFER\r\n");

    		break;
    	case LPUART_UART_IP_EVENT_ERROR:
    		sendstring("LPUART_UART_IP_EVENT_ERROR\r\n");

    		break;
    	//case LPUART_UART_IP_EVENT_IDLE_STATE:

    		//break;
    	default:
    		break;
    	}
    }
}
void LPUART_UART_IP0_IRQHandler()
{
	sendstring("LPUART_UART_IP0_IRQHandler\r\n");
}

 

I would greatly appreciate any advice you can provide. Thank you!

0 件の賞賛
返信
1,474件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the LPUART_UART_IP0_IRQHandler is assigned nowhere so there is no reason to be called.

1) the Lpuart_Uart_Ip_EventType enum of the Events which can trigger UART callback is defined in lpuart_uart_ip_types.h. 
Teh callback with LPUART_UART_IP_EVENT_RX_FULL event is called when defined number of bytes (specified in AsyncReceive function) was received.

2) the LPUART_UART_IP_0_IRQHandler is driver ISR routine assigned for module interrupt. When byte is received/send this handler is called, byte serviced and user callback is called from there if defined event is achieved.

3) you can check in debugger if driver interrupt is get, means LPUART_UART_IP_0_IRQHandler called. if yes then LPUART_UART_IP_EVENT_RX_FULL would be called as well after defined number of bytes is received.

BR, Petr

0 件の賞賛
返信
1,447件の閲覧回数
Pohsuan
Contributor III

I tried implementing the RX interrupt on both UART0 and UART1,

but I couldn't receive the RX_FULL event for either of them.

Additionally, I encountered a LPUART_UART_IP_EVENT_ERROR on UART1.

Pohsuan_0-1739343799211.png


Could you please help me review my code to check if there's anything incorrectly configured?

I would really appreciate your assistance.

0 件の賞賛
返信
1,429件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

do you use own board or EVB? On S32K118EVB you should use different pins then the one selected.

BR, Petr

0 件の賞賛
返信