-
ch32v103 设置中断优先级分组0报错
[i=s] 本帖最后由 Lioyae 于 2024-9-23 14:06 编辑 [/i] [color=#24292e][backcolor=rgb(255, 255, 255)][font="][size=16px]使用CH32V103C8TC设置中断优先级分组时,设置为NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);[/size][/font][/backcolor][/color][color=#24292e][backcolor=rgb(255, 255, 255)][font="][size=16px]编译报错[/size][/font][/backcolor][/color] [img]https://img.picui.cn/free/2024/09/23/66f102cdbadb8.png[/img][color=#24292e][backcolor=rgb(255, 255, 255)][font="][size=16px]而使用NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);[/size][/font][/backcolor][/color] [color=#24292e][backcolor=rgb(255, 255, 255)][font="][size=16px]却不会报错[/size][/font][/backcolor][/color] [img]https://img.picui.cn/free/2024/09/23/66f102cd40b5d.png[/img] 这是什么原因呢??
1867浏览量 4回复量 关注量 -
GD32A503 TIMER 上溢UP中断与CAP中断优先级有一定几率反转问题
测试硬件:GD32A503CC测试外设:TIMER0_CH1 测试准备:PE5输入高频PWM 中断优先级配置:UP中断高于CH1中断 void nvic_configuration(void) { nvic_priority_group_set(NVIC_PRIGROUP_PRE1_SUB3); nvic_irq_enable(TIMER0_BRK_UP_TRG_CMT_IRQn, 1, 0); nvic_irq_enable(TIMER0_Channel_IRQn, 1, 1); } 测试定时器配置:配置TIMER0_CH1为双沿输入捕获模式,使能TIMER0 UP上溢与CH1中断。 void timer_configuration(void) { /* TIMER1 configuration: input capture mode ------------------- the external signal is connected to TIMER0 CH1 pin (PE5) the rising edge is used as active edge the TIMER1 CH0CV is used to compute the frequency value ------------------------------------------------------------ */ timer_ic_parameter_struct timer_icinitpara; timer_parameter_struct timer_initpara; rcu_periph_clock_enable(RCU_TIMER0); timer_deinit(TIMER0); /* TIMER0 configuration */ timer_struct_para_init(&timer_initpara); timer_initpara.prescaler = 99; timer_initpara.alignedmode = TIMER_COUNTER_EDGE; timer_initpara.counterdirection = TIMER_COUNTER_UP; timer_initpara.period = 65535; timer_initpara.clockdivision = TIMER_CKDIV_DIV1; timer_initpara.repetitioncounter = 0; timer_init(TIMER0, &timer_initpara); /* TIMER0 configuration */ /* TIMER0 CH1 input capture configuration */ timer_channel_input_struct_para_init(&timer_icinitpara); timer_icinitpara.icpolarity = TIMER_IC_POLARITY_BOTH_EDGE; timer_icinitpara.icselection = TIMER_IC_SELECTION_DIRECTTI; timer_icinitpara.icprescaler = TIMER_IC_PSC_DIV1; timer_icinitpara.icfilter = 0x0; timer_input_capture_config(TIMER0, TIMER_CH_1, &timer_icinitpara); /* auto-reload preload enable */ timer_auto_reload_shadow_enable(TIMER0); /* clear channel 0 interrupt bit */ timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_UP); /* channel 0 interrupt enable */ timer_interrupt_enable(TIMER0, TIMER_INT_UP); /* clear channel 0 interrupt bit */ timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_CH1); /* channel 0 interrupt enable */ timer_interrupt_enable(TIMER0, TIMER_INT_CH1); /* TIMER0 counter enable */ timer_enable(TIMER0); } 中断处理: __IO uint16_t u16_cap_tick = 0; __IO uint32_t u32_cap_tick = 0; __IO uint32_t u32_cap_tick_pre = 0; __IO uint16_t ovf_cont = 0; __IO uint32_t err_cnt = 0; void TIMER0_BRK_UP_TRG_CMT_IRQHandler(void) { if(SET == timer_interrupt_flag_get(TIMER0, TIMER_INT_FLAG_UP)) { /* clear channel1 interrupt bit */ timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_UP); /* count overflow value */ ovf_cont++; } } void TIMER0_Channel_IRQHandler(void) { if(SET == timer_interrupt_flag_get(TIMER0, TIMER_INT_FLAG_CH1)) { /* clear channel1 interrupt bit */ timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_CH1); /* read channel 1 capture value */ u16_cap_tick = timer_channel_capture_value_register_read(TIMER0, TIMER_CH_1); u32_cap_tick_pre = u32_cap_tick; u32_cap_tick = u16_cap_tick + (ovf_cont << 16); if(u32_cap_tick_pre > u32_cap_tick) { err_cnt++; } } } 出现问题:TIMER0 CNT接近上溢时发生CH1捕获中断, 捕获中断有一定几率先于UP中断处理,导致err_cnt计数错误。 示例中,err_cnt会有计数。
9603浏览量 11回复量 关注量 -
多个中断优先级响应问题
GD32E503配置了超高分辨率定时器中断和普通定时器TIMER1中断,超高分辨率定时器设置为200KHz,中断优先级nvic_irq_enable(SHRTIMER_IRQ0_IRQn, 2, 0);普通定时器200Hz,nvic_irq_enable(TIMER1_IRQn, 1, 0)。两个中断同时开启时,只有超高分辨率定时器的中断函数执行了,有大佬知道为什么吗?
3363浏览量 12回复量 关注量 -
4014触摸中断优先级一样的情况下,Capsense的优先级最高吗?
在不配置使用的外设中断优先级的情况下,在Creator中显示使用的外设中断优先级为3,那么这种情况下,Capsense的中断是不是被优先执行?还是随机的按先响应先执行,执行别的中断函数时不会被Capsense中断打断,谢谢。
1205浏览量 2回复量 关注量 -
kf32ff330 中断优先级问题? sos
INT_Priority_Group_ConfigINT_Interrupt_Priority_Config 这两个函数配置,没有效果,我需要实现强占,请求有谁做过,指导下,谢谢
3229浏览量 0回复量 关注量