本帖最后由 w420028105 于 2013-5-4 23:09 编辑
void PWM_Ini(void)
{
PD_DDR |= 0X18;
PD_CR1 |= 0X18;
CLK_PCKENR1 |= 0X20; //使能TIM2时钟
TIM2_CCMR1 |= 0X68; //PWM1,使能TIM2_CCR1的预装载,设置通道1为输出
TIM2_CCER1 |= 0X01; //低电平有效,使能输出
TIM2_ARR = 1111; //周期为100us
TIM2_CCR1 = 10; //占空比
TIM2_CNTR = 0;
TIM2_PSCR = 0; //不分频
TIM2_CR1 |= 0X81; //使能TIM2_ARR预装载,使能TIM2
while(1);
}
看了网上的其他程序,大都一样的啊,不知道哪里出问题了,是单片机坏了吗,TIM2_CCR1 貌似写不进去,一直是intrusive read? |