How Have UART communication in a Interrupt function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-17 2:43 PM
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​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Solved! Go to Solution.
- Labels:
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-18 3:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-18 3:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-18 3:45 AM
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.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-18 5:45 AM
Very big thanks it worked so fine you resolved a very big problem for my project thanks .;)
