2015-10-19 05:29 AM
Hi Forum,
I am seeing some spurious results when running code and I think it may be interrupt related. To test, I need a quick way of enabling/disabling . There are two types of interrupts running on our system, external (EXTI) and internal timer interrupts.Will the following to the trick to enable and disable all interrupts or just the external ones.
Enable... NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);
Disable..
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; NVIC_Init(&NVIC_InitStructure); If only external interrupts, how could one disable all? Thank you. Bob Carter2015-10-19 09:21 AM
You should be able to enable/disable all the IRQ Handler in the Vector Table at the NVIC, individually. Shouldn't matter if it's the EXTI or TIM, etc.
System Handlers, like SysTick and Faults are different, ie the nIRQ is negativeYou can enable/disable at a chip level __enable_irq() and __disable_irq(), aka cpsie i and cpsid iFinally you can mask at a peripheral level.2015-10-20 05:13 AM
HI Clive,
Thanks for the reply. Will the following do it...NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure); or do I have to disable them individually using..NVIC_DisableIRQ
Cheers
Bob
2015-10-20 06:43 AM
NVIC_Init() will need more parameters in the structure than shown, not sure if that's just the way you cut-n-pasted it.
NVIC_DisableIRQ() would look like a cleaner/simpler way to do it.With the same pre-emption level other interrupts are not going to break into the current one. Normally they'd just tail-chain into the next one. Disabling one, that you're currently servicing, won't allow others to occur until you leave the handler.