2018-12-11 03:05 PM
Hi All,
I have simple code to assign preemption priority and subpriority. I have tested this code on the stm32f103. Even if i set the preemption priority and subpriority, when I read the priority it returns as 0x00.
According to the information from STM32 datasheet the priority register is 0xe000e40e ( NVIC channel 14 belongs to DMA1_Channel4 interrupts).
And I could read 0x00 from that register after NVIC was initialized. It means NVIC channel #14 has the highest priority in the system.
I do not understand that way library function does not work as expected. Do you have any suggestion?
NVIC_InitTypeDef NVIC_InitStructure;
/* DMA1 Channel4 interrupt setting */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 11;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 11;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* -- */
priority = NVIC_GetPriority(DMA1_Channel4_IRQn);
/* -- */
tprintf("\r\nNVIC->IP[DMA1_Channel4_IRQn]=0x%x", NVIC->IP[DMA1_Channel4_IRQn]);
tprintf("\r\npriority= %d ",priority);
The output of the program is:
NVIC->IP[DMA1_Channel4_IRQn]=0x0
priority= 0
Solved! Go to Solution.
2018-12-11 03:30 PM
>> Do you have any suggestion?
Yes, review the group settings of the NVIC, and try setting 1,1
There are only 4-bits to describe *both* Preemption and SubPriorities, setting both to 11 seems to be a bad plan.
2018-12-11 03:30 PM
>> Do you have any suggestion?
Yes, review the group settings of the NVIC, and try setting 1,1
There are only 4-bits to describe *both* Preemption and SubPriorities, setting both to 11 seems to be a bad plan.
2018-12-12 05:19 AM
It is solved thank you.