method for calculating interrupt priority level, PRI_n

method for calculating interrupt priority level, PRI_n

- Priority and subpriority are using the MSB and therefore should be in steps of 16 (eg. 0x10, 0x20, 0x30, etc.) because of the fixed number of priority levels (= 16) in the priority level register.

The value is: ((priority < (group + 1)) + (subpriority < 4))

In your example 1: number of subpriority bits are 0, so there are no subpriorities. The correct result should be 0,0,0,16,16,16,32,32. In your example 2: number of subpriority bits are 1, subpriority 2 or 5 are not supported.

You can find more detailed info in "The Definitive Guide to them ARM Cortex-M3", from Joseph Yiu, page 117ff.

I understand the PRI_n is the priority for the interrupt and its range is 0 to 255. I took some examples from the STM32 library but I do not understand them.

Putting some example numbers into NVIC_Init of the STM32 library returns the following PRI_n numbers.

I predicted PRI_N would be equal to (Pre-emption)*(pre-emption_bits) + (subpriority) as I showed above but I must be wrong. Can anyone explain how to get the value of PRI_n?

[ This message was edited by: jeff.heiss on 13-07-2008 23:30 ]