|
发表于 2015-4-20 14:41:35
只看该作者
沙发
本帖最后由 FireBLE_blue 于 2015-4-21 15:30 编辑
hi,thong
你说的自带的pwm例程是否是 \FireBLE\Demo_driver\pwm 下编译而来?如是请看确认main 函数和如下代码一致
- int main (void)
- {
- SystemInit();
- pwm_init(PWM_CH0);
- pwm_io_config();
- //P2.7 will output pwm wave with period for 1000us and pulse for 400us
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(400, PWM_PSCAL_DIV));
- pwm_enable(PWM_CH0, MASK_ENABLE);
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(800, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(1000, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(0, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(400, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(800, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(1000, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(0, PWM_PSCAL_DIV));
- pwm_config(PWM_CH0, PWM_PSCAL_DIV, PWM_COUNT_US(1000, PWM_PSCAL_DIV), PWM_COUNT_US(800, PWM_PSCAL_DIV));
- pwm_enable(PWM_CH0, MASK_DISABLE);
- pwm_io_dis_config();
- pwm_init(PWM_CH1);
- pwm_io_config();
- //P2.6 will output pwm wave with period for 1500us and pulse for 1000us
- pwm_config(PWM_CH1, 119, PWM_COUNT_US(1500, 119), PWM_COUNT_US(1000, 119));
- pwm_enable(PWM_CH1, MASK_ENABLE);
- pwm_io_dis_config();
- while (1) /* Loop forever */
- {
- }
- }
复制代码
该份代码在单步仿真的情况下能得到pwm 输出,
如果你是编译后烧录进去的话,需要对代码做些小改动,至于怎么改动,请分析源码 |
|