writing to SHPR2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,

What is wrong with this code?
When I debug it in DAVE4 with XMC1100 Boot Kit the SHPR2 register not changing in the debugger.
The code is based on EasyMain (LED blinking is working for example with a modified main)


#include "XMC1100.h"


int main(void)
{
unsigned int a;

a = 0x0B << PPB_SHPR2_PRI_11_Pos;
PPB->SHPR2 |= a;

while(1);
}
0 Likes
1 Reply
chismo
Employee
Employee
First like received
Hello,

The XMC1100 is based on Cortex-M0, which supports 4 priority levels. Therefore effectively only the MSB 2 bits of the priority bit fields are used.

From your code, you are effectively writing 0 to SHPR2. You should write:
- 0x0 for priority 0
- 0x40 for priority 1
- 0x80 for priority 2
- 0xC0 for priority 3

But easiest is to use the CMSIS function, for example to select priority 3:
NVIC_SetPriority(SVCall_IRQn, 3);

Regards,
Min Wei
0 Likes