PWM捕获
/* set PWMB channel 2 capture configuration */
PWM_ConfigCaptureChannel(PWMB, PWM_CH2, 166, 0);
/* Enable capture falling edge interrupt for PWMB channel 2 */
PWM_EnableCaptureInt(PWMB, PWM_CH2, PWM_CAPTURE_INT_FALLING_LATCH);
/* Enable PWMB NVIC interrupt */
NVIC_EnableIRQ((IRQn_Type)(PWMB_IRQn));
/* Enable Timer for PWMB channel 2 */
PWM_Start(PWMB, 0x4);
/* Enable Capture Function for PWMB channel 2 */
PWM_EnableCapture(PWMB, 0x4);
配置通道和参数,其实我觉得166这个参数最好由系统自动配置比较好,在函数里实现,获取配置使用的时钟源和分频,经过一个计算就可以自动实现了,还要人算,费时
|