这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » PWM波不输出?

共2条 1/1 1 跳转至

PWM波不输出?

菜鸟
2008-06-23 17:37:57     打赏

请帮忙看一下程序,中断可以进,
为什么不能连续输出脉冲?设成连续模式也还是不行。在复位后只可以看到一个脉冲。
用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;

}




关键词: 波不     输出    

菜鸟
2008-06-24 14:48:06     打赏
2楼

三个值应该相同,设成不同值想测一下不同设置对输出的作用。中断可以进,在中断中加入串口数据发送,可以工作。但不知中断后对某个寄存器是否要清零或要其他设置才能触发下次波形输出。
另外,电路是我自己搭的电路,p85脚接高电平。
笔记已下载,正在学习,谢谢。


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]