TI中文支持网
TI专业的中文技术问题搜集分享网站

T1PWM无法改变占空比?改变T1CPMR没有一丝变化,为什么呀

	//EVA模块

	//主要设置T1PWM引脚
	EvaRegs.T1PR			= 2929;	//约为2.5MS PWM周期为(T1PR+1)/(75/64)M=2.5ms
	EvaRegs.T1CMPR			= 0;	//Timer1 compare
	EvaRegs.T1CNT			= 0x0000;	//Timer1 counter
	EvaRegs.T1CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,设置高速时钟64分频
//	EvaRegs.T1CON.bit.TPS 	= 6;	//设置高速时钟64分频
	//主要设置T2PWM引脚
	EvaRegs.T2PR			= 2929;	//Timer2 period
	EvaRegs.T2CMPR			= 0;	//Timer2 compare
	EvaRegs.T2CNT			= 0x0000;	//Timer2 counter
	EvaRegs.T2CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,与T1同步,设置高速时钟64分频
//	EvaRegs.T2CON.bit.TPS	= 6;	//设置高速时钟64分频

	EvaRegs.GPTCONA.bit.TCOMPOE = 1;//设置引脚T1PWM_T1CMP,T2PWM_T2CMP由定时器1和2独立驱动PWM
	EvaRegs.GPTCONA.bit.T1PIN  = 1;//设置低有效
	EvaRegs.GPTCONA.bit.T2PIN  = 1;//设置低有效

	//EVB模块

	//主要设置T3PWM引脚
	EvbRegs.T3PR			= 2929;	//Timer1 period
	EvbRegs.T3CMPR			= 0;	//Timer1 compare
	EvbRegs.T3CNT			= 0x0000;	//Timer1 counter
	EvbRegs.T3CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,设置高速时钟64分频
//	EvbRegs.T3CON.bit.TPS	= 6;	//设置高速时钟64分频 = 2*2*2*2*2*2 = 2^6
	//主要设置T4PWM引脚
	EvbRegs.T4PR			= 2929;	//Timer2 period
	EvbRegs.T4CMPR			= 0;	//Timer2 compare
	EvbRegs.T4CNT			= 0x0000;	//Timer2 counter
	EvbRegs.T4CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,与T3同步,设置高速时钟64分频
//	EvbRegs.T4CON.bit.TPS	= 6;	//设置高速时钟64分频 = 2*2*2*2*2*2 = 2^6

	EvbRegs.GPTCONB.bit.TCOMPOE = 1;//设置引脚T1PWM_T1CMP,T2PWM_T2CMP由定时器1和2独立驱动PWM
	EvbRegs.GPTCONB.bit.T3PIN  = 1;//设置低有效
	EvbRegs.GPTCONB.bit.T4PIN  = 1;//设置低有效

//	 EvaRegs.COMCONA.bit.CENABLE=1;//使能比较单元的比较操作
//EvaRegs.COMCONA.bit.FCOMPOE=1;//全比较输出,PWM1-6引脚均由相应的比较逻辑驱动
//	 EvaRegs.COMCONA.bit.CLD=2;

//	EvbRegs.COMCONB.bit.CENABLE=1;//使能比较单元的比较操作
//	EvbRegs.COMCONB.bit.FCOMPOE=1;//全比较输出,PWM7-12引脚均由相应的比较逻辑驱动
//	EvbRegs.COMCONB.bit.CLD=2;EvaRegs.EVAIMRA.bit.T1PINT=1;//使能周期中断EvaRegs.EVAIFRA.bit.T1PINT=1;//周期中断标志位清除

mangui zhang:

如果正常情况   CPMR改变肯定会改变PWM波的占空比

你是不是侧错引脚了

	//EVA模块

	//主要设置T1PWM引脚
	EvaRegs.T1PR			= 2929;	//约为2.5MS PWM周期为(T1PR+1)/(75/64)M=2.5ms
	EvaRegs.T1CMPR			= 0;	//Timer1 compare
	EvaRegs.T1CNT			= 0x0000;	//Timer1 counter
	EvaRegs.T1CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,设置高速时钟64分频
//	EvaRegs.T1CON.bit.TPS 	= 6;	//设置高速时钟64分频
	//主要设置T2PWM引脚
	EvaRegs.T2PR			= 2929;	//Timer2 period
	EvaRegs.T2CMPR			= 0;	//Timer2 compare
	EvaRegs.T2CNT			= 0x0000;	//Timer2 counter
	EvaRegs.T2CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,与T1同步,设置高速时钟64分频
//	EvaRegs.T2CON.bit.TPS	= 6;	//设置高速时钟64分频

	EvaRegs.GPTCONA.bit.TCOMPOE = 1;//设置引脚T1PWM_T1CMP,T2PWM_T2CMP由定时器1和2独立驱动PWM
	EvaRegs.GPTCONA.bit.T1PIN  = 1;//设置低有效
	EvaRegs.GPTCONA.bit.T2PIN  = 1;//设置低有效

	//EVB模块

	//主要设置T3PWM引脚
	EvbRegs.T3PR			= 2929;	//Timer1 period
	EvbRegs.T3CMPR			= 0;	//Timer1 compare
	EvbRegs.T3CNT			= 0x0000;	//Timer1 counter
	EvbRegs.T3CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,设置高速时钟64分频
//	EvbRegs.T3CON.bit.TPS	= 6;	//设置高速时钟64分频 = 2*2*2*2*2*2 = 2^6
	//主要设置T4PWM引脚
	EvbRegs.T4PR			= 2929;	//Timer2 period
	EvbRegs.T4CMPR			= 0;	//Timer2 compare
	EvbRegs.T4CNT			= 0x0000;	//Timer2 counter
	EvbRegs.T4CON.all		= 0x1602;	//连续增计数模式,使能定时器,比较使能,与T3同步,设置高速时钟64分频
//	EvbRegs.T4CON.bit.TPS	= 6;	//设置高速时钟64分频 = 2*2*2*2*2*2 = 2^6

	EvbRegs.GPTCONB.bit.TCOMPOE = 1;//设置引脚T1PWM_T1CMP,T2PWM_T2CMP由定时器1和2独立驱动PWM
	EvbRegs.GPTCONB.bit.T3PIN  = 1;//设置低有效
	EvbRegs.GPTCONB.bit.T4PIN  = 1;//设置低有效

//	 EvaRegs.COMCONA.bit.CENABLE=1;//使能比较单元的比较操作
//EvaRegs.COMCONA.bit.FCOMPOE=1;//全比较输出,PWM1-6引脚均由相应的比较逻辑驱动
//	 EvaRegs.COMCONA.bit.CLD=2;

//	EvbRegs.COMCONB.bit.CENABLE=1;//使能比较单元的比较操作
//	EvbRegs.COMCONB.bit.FCOMPOE=1;//全比较输出,PWM7-12引脚均由相应的比较逻辑驱动
//	EvbRegs.COMCONB.bit.CLD=2;EvaRegs.EVAIMRA.bit.T1PINT=1;//使能周期中断EvaRegs.EVAIFRA.bit.T1PINT=1;//周期中断标志位清除

bolin li:

回复 mangui zhang:

不会啊,我是用示波器测的,另外,中断会影响到占空比吗?

赞(0)
未经允许不得转载:TI中文支持网 » T1PWM无法改变占空比?改变T1CPMR没有一丝变化,为什么呀
分享到: 更多 (0)