- 打卡等级:偶尔看看I
- 打卡总天数:17
- 最近打卡:2024-09-17 10:21:00
注册会员
- 积分
- 169
|
本帖最后由 i_zw 于 2024-9-1 20:28 编辑
通过PWM产生了需要的频率1.14M Hz。
void PWM_init()
{
P_SW2 |= 0x80;
PWMA_PS=0x10; //select PWMA3Pin P:P24,N:P25 -useP24
PWMA_CCER2 = 0x00; // before update CCMRx ,reset CCERx to close PWMA/B channel, clear
PWMA_CCMR3 = 0x60; //set PWMA channel,mode 1
PWMA_CCER2 = 0x01; //config PWMA channel enable OUT,PWMA3P ,
PWMA_CCR3 = 14;//PWM_DUTY; // occupation count
PWMA_ARR = 28;//PWM_PERIOD; // period count
PWMA_ENO = 0x10; //ennabe OUT.PWMA3P
PWMA_BKR = 0x80; //enable main OUT
PWMA_CR1 = 0x01; //start counter
}
只是又遇到一个问题,用PWM产生的方波频率,在定时timer中通过PWMA_CR1 =0x00和0x01 启动和停止后,不确定是停止在高电平还是低电平,请问这个有方法控制吗
定时启停代码
if(longtime<500)
{
longtime++;
}else
{
longtime=0;
if(PWMA_CR1&0x01==0x01)
PWMA_CR1=0x00;
else
PWMA_CR1=0x01;
P24=0; //没有作用,应该是PWMA_CR1赋值后,PWM 没有立即停止
}
|
|