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
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;
}
2019-03-04 09:46 PM
How about __disable_irq() and __enable_irq()?
2019-03-06 01: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;
}
2019-03-06 01: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.
2019-03-06 01:20 PM
They don't nest..