|
我的cpu是三星的2442,我想配置一下pwm timer,输出一个pwm脉冲,可是用示波器在cpu的输出管脚老是不能检测到脉冲,高手帮忙看看是哪里配置错了。我采用的是autoload的方式,需要在中断响应函数里面处理相应的pwm timer产生的中断吗,如果要的话,该怎么处理呢?清除timer产生的中断标志?我试过了都没什么变化,不知道是不是处理的不对。
volatile S3C2440A_PWM_REG *s2440PWMREG = (S3C2440A_PWM_REG *)OALPAtoVA(S3C2440A_BASE_REG_PA_PWM, FALSE);
UINT32 tcon;
UINT32 TimerCfg=0;
s2440IOP->GPBDAT = 0x6f;
s2440IOP->GPBDN = 0x7FF;
s2440IOP->GPBCON = 0x2A966A; // 0,1 as timer , 2,3 as output
TimerCfg = INREG32(&s2440PWMREG->TCFG0);
TimerCfg&=~(0xff); //clear the low 8 bits
TimerCfg|=0x7f; //set prescaler to 127
OUTREG32(&s2440PWMREG->TCFG0, TimerCfg);
// Select MUX input 1/2
OUTREG32(&s2440PWMREG->TCFG1, INREG32(&s2440PWMREG->TCFG1) & ~(0x000000ff)); // set Timer0,1 Division to 1/2
// Set timer register
OUTREG32(&s2440PWMREG->TCNTB0,1000); //count buffer
OUTREG32(&s2440PWMREG->TCMPB0,500); //compare buffer
OUTREG32(&s2440PWMREG->TCNTB1,1000); //count buffer
OUTREG32(&s2440PWMREG->TCMPB1,500); //compare buffer
// Start timer in auto reload mode
tcon = INREG32(&s2440PWMREG->TCON);
tcon &= 0x000; //clear bit 0~11
tcon |=(1<<9 | 1<<1); // update TCNTBn,TCMPBn
tcon |= (1<<3 | 1<<11); //timer 0,1 auto reload
OUTREG32(&s2440PWMREG->TCON, tcon);
tcon = INREG32(&s2440PWMREG->TCON);
tcon |= (1<<0 | 1<<8);
OUTREG32(&s2440PWMREG->TCON, tcon );
tcon = INREG32(&s2440PWMREG->TCON);
tcon &= 0xfffffdfd; //clear update bit
OUTREG32(&s2440PWMREG->TCON, tcon); //clear manual update bit
|
|