Disable/enable interrupts globally on STM32F746
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 10:21 AM
Hello,
just a simple question. We share some data between ISR and application on STM32F746 processor (no RTOS used). How can we disable interrupts globally while application accesses the shared variables? Afterwards interrupts should be enabled again.
Thanks Marc
- Labels:
-
Interrupt
-
STM32F7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 10:23 AM
uint32_t SPIP_MasterRunTransaction(SPIP_t* pSPIP) {
uint32_t tmp;
tmp = __get_PRIMASK();
__set_PRIMASK(tmp | 1);
SPIP_InterruptBasedStateMachine(0);
__set_PRIMASK(tmp);
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 9:46 PM
How about __disable_irq() and __enable_irq()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-06 1:08 PM
Interrupt can still get in between lines 3-4 and change PRIMASK.
uint32_t SPIP_MasterRunTransaction(SPIP_t* pSPIP) {
uint32_t tmp;
__disable_irq();
tmp = __get_PRIMASK();
__set_PRIMASK(tmp | 1);
__enable_irq();
SPIP_InterruptBasedStateMachine(0);
__set_PRIMASK(tmp);
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-06 1:13 PM
When accessing shared data, often it's enough to disable/enable interrupts only for particular peripheral with NVIC_DisableIRQ() and NVIC_EnableIRQ() respectively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-06 1:20 PM
They don't nest..
Up vote any posts that you find helpful, it shows what's working..
