cancel
Showing results for 
Search instead for 
Did you mean: 

Priorities on STM32 (USB, SD, EXTI...)

bmak
Senior

Hi,

please help me figure out priorities in my project.

So, I'm using:

  • SDIO 4 bit + DMA
  • USB Composite Device = CDC + MSC with VBUS detection on PA9 pin.

I configured PA9 as EXTI on Rising/Falling edge. For now i just want to light a diode when USB conection is detected. It works on simplier project with just USB device CDC.

My priorities:

  • SDIO global interrupt - Preemption priority 1
  • DMA2 stream3 and stream 6 global interrupt - Preemption priority 2
  • USB OTG FS global interrupt - Preemption priority 5

All sub priorities are 0.

I tried giving EXTI9_5 (PA9 pin) preemption priority from 0 to 6, and also preemption priority 5 with subpriority 1.

I know that the higher number it is, the lower priority it gets. My guess is that EXTI should have the last priority, but I'm not sure.

My MCU is STM32F407VG.

Thanks, and have a nice day!

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

This is correct. Numerically lower priorities will pre-empt numerically higher ones.

The usual method (and typically best) is not to use subpriorities at all and assign all 4 bits to preemption.

> My guess is that EXTI should have the last priority, but I'm not sure.

It's your choice. Anything should work here.

Consider debouncing the line, and/or delaying USB initialization for 100ms after the line goes high.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

1 REPLY 1
TDK
Guru

This is correct. Numerically lower priorities will pre-empt numerically higher ones.

The usual method (and typically best) is not to use subpriorities at all and assign all 4 bits to preemption.

> My guess is that EXTI should have the last priority, but I'm not sure.

It's your choice. Anything should work here.

Consider debouncing the line, and/or delaying USB initialization for 100ms after the line goes high.

If you feel a post has answered your question, please click "Accept as Solution".