cancel
Showing results for 
Search instead for 
Did you mean: 

How Have UART communication in a Interrupt function

HDIA.1
Associate III

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​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

1 ACCEPTED SOLUTION

Accepted Solutions
Nikita91
Lead II

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

View solution in original post

3 REPLIES 3
Nikita91
Lead II

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

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
Up vote any posts that you find helpful, it shows what's working..

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