智能车制作
标题:
求助!定时器产生PWM程序问题
[打印本页]
作者:
wenxijun1010
时间:
2011-4-19 12:33
标题:
求助!定时器产生PWM程序问题
本人新手 ,用定时器产生PWM信号,下面是初始化
void PWM1_Init(void)
{
/* T2SC: TOF=0,TOIE=0,TSTOP=1,TRST=1,??=0,PS2=0,PS1=0,PS0=1 */
T2SC = 0x31; /* Stop and reset counter */
RatioStore = 0xECCC; /* Store initial value of the ratio */
T2MOD = 0x9C3F; /* and to the period-modulo register , T2MOD = 39999 */
T2CH0 = 0x9087; /* Store initial value to the duty-compare register,T2CH0 = 36999 */
/* T2SC0: CH0F=0,CH0IE=0,MS0B=0,MS0A=1,ELS0B=0,ELS0A=0,TOV0=1,CH0MAX=0 */
T2SC0 = 0x12; /* Set output signal level to low */
/* T2SC0: CH0F=0,CH0IE=0,MS0B=0,MS0A=1,ELS0B=1,ELS0A=1,TOV0=1,CH0MAX=0 */
T2SC0 = 0x1E; /* Set up PWM mode */
}
周期20ms,预想设置脉宽为1.5ms,
先前已经编译过,但出现的信号脉宽为18.5ms,于是设置T2CH0 = 0x0BB7(2999),编译后仿真,出现的信号脉宽还是18.5ms,这是为什么啊??那应该怎么改变参数才能使脉宽为1.5ms呢??新手求解答!
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2