LPUART Tx inside an ISR

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

LPUART Tx inside an ISR

987 Views
alberto_florio
Contributor I

Hi,

I'm trying to send a string message via LPUART1 inside a PORTC Interrupt Service Routine. I configured the LPUART with DMA (Ch1 Rx and Ch2 Tx). Inside the ISR I call the function:

LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)msg, strlen(msg));

to send the string msg on a terminal.

The result is that if i press SW3 or SW4 on the S32K148 EVB the ISR is called correctly, but on the terminal the message start a infinite loop. My goal is to send msg each time the ISR is executed.

If I use LPUART_DRV_SendData to send a message in the main function it works as expected.

Can someone please help me to understand this behaviour?

Thanks

0 Kudos
Reply
2 Replies

857 Views
B46399
NXP Employee
NXP Employee

Hi, Alberto!

LPUART_DRV_SendData function uses some interrupts itself (even when the transfer is DMA based - there is one interrupt at the end of the transfer), so it might be affected by the fact that it's called from an interrupt context (depending on latencies, priorities etc). A first piece of advise would be to only update a volatile flag inside the PORT ISR, then use that for triggering the UART transfer from the thread context.

If this still doesn't work, please try to attach your application code so we can take a closer look.

Regards,

Vlad Lionte

857 Views
alberto_florio
Contributor I

Thank you Vlad, I missed the interrupt at the end of DMA transfer.

Regards

Alberto

0 Kudos
Reply