openwch / ch32v003

CH32V003 is an ultra-cheap RISC-V MCU with 2KB SRAM, 16KB flash, and up to 18 GPIOs that sells for under $0.10
393 stars 58 forks source link

NVIC priority setting is not working #30

Closed greenscreenflicker closed 11 months ago

greenscreenflicker commented 1 year ago

Hello, I have the following setup: Systick is running a simple taskcaller, while a control loop is run by a DMA interrupt. The DMA interrupt should always have the higher priority.

main.c: NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

control.c

void control_init(void){
    NVIC_InitTypeDef NVIC_InitStructure = {0};
    NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

systic.c

void taskcaller_init(void) {
    NVIC_InitTypeDef NVIC_InitStructure = {0};
    NVIC_InitStructure.NVIC_IRQChannel = SysTicK_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

However, the systick is not interrupted by the control.

Can you please advise how to get Systick_IRQ priority lower than the DMA priority?

EDIT: I tryed reversing prioritys (lower=higher, same effect). I'm desperate for advice.