static uint32_t SysTick_Config(uint32_t ticks) { SysTick->CTLR = 0x00000000; //控制寄存器复位 SysTick->SR = 0x00000000; //状态寄存器复位 SysTick->CNT = 0x00000000; //计数器复位,设置初始值为0 SysTick->CMP = ticks; //给重加载寄存器赋值 NVIC_SetPriority(SysTicK_IRQn, 15); //设置SysTick中断优先级 NVIC_EnableIRQ(SysTicK_IRQn); //使能开启Systick中断 SysTick->CTLR |= 0x0000000B; //启动系统计数器STK(HCLK/8时基) return (0); }
void drv_tim3_init(u16 hz) { TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure = {0}; NVIC_InitTypeDef NVIC_InitStructure = {0}; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_TimeBaseInitStructure.TIM_Period = 100000 / hz; TIM_TimeBaseInitStructure.TIM_Prescaler = SystemCoreClock / 100000; TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0x00; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStructure); TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); TIM_Cmd(TIM3, DISABLE); }
CH32V203配置的两个中断,当timer3中断产生的时候,systicKZ中断就不能正常中断,中断嵌套的功能怎么没有实现?是否是我的配置有问题?
热门产品 :
CH641: PD及无线充电专用MCU