智能车制作
标题:
K10 PWM初始化问题
[打印本页]
作者:
沒那麼簡單
时间:
2014-5-14 23:59
标题:
K10 PWM初始化问题
void FTM_Init(void) {
PORTA_PCR4= PORT_PCR_MUX(3);
SIM_SCGC6|=SIM_SCGC6_FTM0_MASK;
FTM0_MODE |= FTM_MODE_WPDIS_MASK;
FTM0_C1SC |= FTM_CnSC_ELSB_MASK;
FTM0_C1SC &= ~FTM_CnSC_ELSA_MASK;
FTM0_C1SC |= FTM_CnSC_MSB_MASK;
FTM0_SC=0x0c;
FTM0_MODE &= ~1;//这个不太懂,感觉就相当于没赋值···
FTM0_OUTMASK=0x02;
FTM0_QDCTRL&=~FTM_QDCTRL_QUADEN_MASK;//禁止正交解码模式
FTM0_COMBINE=0;
FTM0_CNTIN=0;
FTM0_CNT=0;
FTM0_MOD=37499;
FTM0_C1V=5625;
SIM_SCGC5 |=SIM_SCGC5_PORTA_MASK;
PORTA_PCR15|=0X0;
PORTA_PCR15|=(1<<8);
GPIOA_PDDR|=(1<<15);
GPIOA_PDOR|=(0<<15);
}
总线时钟60M,A15端口的灯亮了,但是A4口一直是高电平(3.3V),谁能告诉我程序哪里出错了?
另外一种初始化:
void PWM_Init( void ){
PORTA_PCR4&=~(PORT_PCR_MUX_MASK);
PORTA_PCR4 |= PORT_PCR_MUX(3);
GPIOA_PDDR|=(1<<4);
SIM_SCGC6 |= SIM_SCGC6_FTM0_MASK;
FTM0_CNTIN|=0x0;
FTM0_CNT|=0x0;
FTM0_MOD|=0Xbb7;
FTM0_C1SC|=0X28;
FTM0_C1V|=0X5dc;
FTM0_SYNC|=(1<<2)|(1<<7);//与上面的初始化程序设置不同
FTM0_OUTINIT|=0X02;//
FTM0_COMBINE|=(1<<5);//
FTM0_MODE|=7;
FTM0_SC|=0X28;
}
求助!!
作者:
沒那麼簡單
时间:
2014-5-15 00:16
不能沉,我还在等着回复
作者:
沒那麼簡單
时间:
2014-5-15 23:32
等··················
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2