Detecting what interrupt was triggered

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
dolfandringa
Posts: 20
Joined: Wed Jun 03, 2020 3:47 am

Detecting what interrupt was triggered

Post by dolfandringa »

Using the STM32 Arduino Core on an STM32F103C8, I am having an issue, probably with a 3rd party library, where some interrupt gets triggered, causing LowPower.deepSleep to wakeup straight away, instead of sleeping until the RTC alarm occurs. Is there a way to see what interrupts get triggered, and as a consequence, detect what woke my device up?

Cheers,

Dolf.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Detecting what interrupt was triggered

Post by fpiSTM »

Please avoid to open an other discussion.

As said in the other topic, you will have to debug and check peripheral registers states. Usinog PIO, VSCode,...
Up to you to use your preferred IDE and debugger.
dolfandringa
Posts: 20
Joined: Wed Jun 03, 2020 3:47 am

Re: Detecting what interrupt was triggered

Post by dolfandringa »

Ok, but can you elaborate a little on which registers I need to check? I am browsing through the STM32 reference manual and code, but there is so much of it that it's hard to figure out which ones I need to check, and how I can disable interrupts. Are there functions or specific registers that tell me what interrupts were triggered? And which function can I use to disable specific interrupts? It is hard to find decent documentation on the STM32 Arduino Core about this stuff.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Detecting what interrupt was triggered

Post by fpiSTM »

You can use the HALL or LL API for doing this oand also CMSIS one.
I've not the API in mind but something like:

Code: Select all

void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn);

https://www.google.com/url?sa=t&rct=j&q ... 8NyT4_GyFv
dolfandringa
Posts: 20
Joined: Wed Jun 03, 2020 3:47 am

Re: Detecting what interrupt was triggered

Post by dolfandringa »

Cool, thanks again for your help @fpiSTM . I didn't know that doc existed. It helps a lot. But it turns out the IRQ was triggered by my STLink debugger. I am using it to upload the code. Even without actually debugging, it looks like after flashing the code, the STLink debugger triggers an interrupt that wakes up the MCU. Just a power cycle solves the issue. I can leave the STLink connected, but just need to power cycle the device after uploading the code. A reset isn't enough.
Post Reply

Return to “General discussion”