这几天一直在使用STM32来写sensorless BLDC的驱动框架,那么必须会用到TIM1的CCR1/CCR2/CCR3产生的六路互补PWM,以及用CCR4来产生一个中断,用来在PWM-ON的时候产生中断进行过零检测,以及相电流的检测等。
这几天一直在测试PWM,CCR4的中断,ADC1的采样触发+DMA等功能,现在也了解的差不多了,先记录下来,先看下我的一些设置,TIM1设置:
1 /* Time Base configuration ,init time1 freq*/ 2 TIM_TimeBaseStructure.TIM_Period = Period; 3 TIM_TimeBaseStructure.TIM_Prescaler = 0; 4 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 5 TIM_TimeBaseStructure.TIM_ClockDivision = 0; 6 TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; 7 TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); 8 9 /* Automatic Output enable, Break, dead time and lock configuration*/ 10 TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable; 11 TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable; 12 TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_OFF; 13 TIM_BDTRInitStructure.TIM_DeadTime = 0; 14 TIM_BDTRInitStructure.TIM_Break =