请帮忙看一下程序,中断可以进,
为什么不能连续输出脉冲?设成连续模式也还是不行。在复位后只可以看到一个脉冲。
用30281
先谢谢了。
void init_pwm(void)
{
/* induced voltage signal input setting */
int4ic = 0x00; /* set both edge */
int3ic = 0x00;
int5ic = 0x00;
ifsr = 0xf8;
/* three-phase PWM initial setting */
ictb2 = 1; /* one TB2 underflow interrupt */
prcr = 0x02;
invc0 = 0x07 ; /* sawtooth modulation mode, no two active at an instance */
invc1 = 0x50; /* invalid short-circuit protection time, active */
prcr = 0x00;
prcr = 0x02;
tb2sc = 0x00;
idb0 = 0x30; /* set three-phase output buffer register 0 */
idb1 = 0x30; /* set three-phase output buffer register 1 */
prcr = 0x00;
ta1mr = 0x13; /* one-shot pulse mode */
ta2mr = 0x12; /* one-shot pulse mode */
ta4mr = 0x12; /* one-shot pulse mode */
tb2mr = 0x00; /* timer mode */
trgsr = 0x45; /* trigger select register TB2 trigger */
tb2 = 0xfff- 1; /* carrier cycle */
ta4 = ta1 = ta2 = 0x8ff; /* initial DUTY */
tb2ic = 0x06; /* TB2 interrupt enable */
tabsr |= 0x96; /* tiemr count start */
prcr = 0x02;
invc0 |= 0x08; /* output enable */
prcr = 0x00;
asm("fset I");
}
/*/////////////////////////////////////////////////////////////////////////////
// PWM Interrupt Enable pwm 中断设置初始化
//////////////////////////////////////////////////////////////////////////////*/
void pwm_int(void)
{
stg_i++;
if (stg_i >= 6)
{
stg_i=0;
if (stg_p <= 10) stg_p++;
else stg_p=0;
}
idb0 = pwm_out_tbl0[stg_p];
idb1 = pwm_out_tbl1[stg_p];
tb2 = 0xfff- 1; /* carrier cycle */
ta4 = ta1 = ta2 = 0x8ff; /* initial DUTY */
tabsr |= 0x96; /* tiemr count start */
tb2sc = 0x00;
}