大红鹰娱乐官网风格切换切换到宽版
  • 3640阅读
  • 0回复

[SH]ATU初始化 [复制链接]

上一主题 下一主题
离线lf582127667
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2014-02-10

自己写的ATU初始化程序,求大神给看看那里出问题了。编译能通过,调试的时候io,寄存器都没有反应


void ATU_PWM(void);

void ATU_PWM(void)
{   /*---- IO pin setting ----*/
/* PWM = PB4, 132# */
#if 0
PORTB.DR.WORD |= BIT00;     /* Data: 1 */
PORTB.IR.WORD &= ~BIT00;    /* Invert: No */
PORTB.DSR.WORD &= ~BIT00;    /* Drive capability: Normal */
    #endif
PORTB.CR2.BIT.MD4 = 0U;    
PORTB.CR2A.BIT.MD4=1U;                  /* Function: PWM Output */
PORTB.IOR.WORD = 0X00;    /* Direction: Output */

ATUCTRL.ATUENR.BIT.TEE=1U;//Enable TimerE
TIMERE.TSTRE.BIT.STRE0=1U;//Enable SUBBLOCK E0
TIMERE.SUBBLOCK[0].SSTRE.BIT.SSTRE0=0x01;//Enable counter of channal 0 in subblock E0


/*---------select the clock--------*/
TIMERE.SUBBLOCK[0].PSCRE.BIT.PSCE=0X04;//
TIMERE.SUBBLOCK[0].TCRE.BIT.CKSELE=0X00;//时钟选择

/*----------  --------*/
TIMERE.SUBBLOCK[0].TSRE.BIT.OVFE0=0U;//NO OVERFLOWED
TIMERE.SUBBLOCK[0].TSRE.BIT.CMFE0=0U;//HAS NO CYCLE MATCH
TIMERE.SUBBLOCK[0].TIERE.BIT.CMEE0=0U;//Disable interrupt request
TIMERE.SUBBLOCK[0].TOCRE.BIT.TONEE0=0U;//Signal is output as is on PWM output pin
TIMERE.SUBBLOCK[0].TCNTE[0]=0X0002;

/*--------PWM frequency setting----*/
/*--------f=1.25kHz----------------*/
TIMERE.SUBBLOCK[0].CYLRE[0]=0X1F40;
TIMERE.SUBBLOCK[0].CRLDE[0]=0X1F40;
TIMERE.SUBBLOCK[0].DTRE[0]=0X0FA0;
TIMERE.SUBBLOCK[0].DRLDE[0]=0X0FA0;
}
博聚网