NVIC_Init() library function does not work as expected
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 