Skip to main content
HDIA.1
Associate III
December 17, 2021
Solved

How Have UART communication in a Interrupt function

Hello ,

​

So for my project i need to send UART command every 15min

​

Between this my MCU need to be sleeping ​

​

And send a command if a Interrupt pin change state​

​

But when i wrote UART_transmit fonction in a ISR : RTC , timer , interrupt pin the command isn't send

​

In internet people says that interrupt function can't handle UART so how solve my issue

​

Thanks​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

This topic has been closed for replies.
Nikita91
Nikita91Best answer
Lead II
December 18, 2021

In the interrupt set a flag.

Then in your main routine check the flag and if it is set then send the UART message and reset the flag.

If your MCU is sleeping (in wfi I presume) it is awaken by an interrupt. They you have to test the flags when the MCU resume from wfi.

It is good practice to get short ISR

3 replies

Nikita91
Nikita91Best answer
Lead II
December 18, 2021

In the interrupt set a flag.

Then in your main routine check the flag and if it is set then send the UART message and reset the flag.

If your MCU is sleeping (in wfi I presume) it is awaken by an interrupt. They you have to test the flags when the MCU resume from wfi.

It is good practice to get short ISR

HDIA.1
HDIA.1Author
Associate III
December 18, 2021

Very big thanks it worked so fine you resolved a very big problem for my project thanks .;)

Tesla DeLorean
Guru
December 18, 2021

Put the data strings you want to send into a FIFO / ring buffer, and then enable the UART TXE interrupt bit, this will cause the UART interrupt to push data out at its own rate whilst letting your other interrupt finish immediately.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..