初始化程序仅供参考!
/************************************************************************************
Name: timer_rc_init
Parameters: None
Returns: None
Description: Initial setting of Timer RC SFR
从P35口输出PWM波形,trcgra 控制周期 trcgrd控制占空比
************************************************************************************/
void timer_rc_init(void){
ea_trcoer = 1;
eb_trcoer = 1;
ec_trcoer = 1;
ed_trcoer = 0; /* TRCIOD Pin:P3_5 */
tstart_trcmr = 0; /* Stop TRC Count */
trcic = 0x00; /* Interrupt disabled */
pwmb_trcmr = 1; /* TRCIOB PWM mode selection bit:PWM mode */
pwmc_trcmr = 1; /* TRCIOC PWM mode selection bit:PWM mode */
pwmd_trcmr = 1; /* TRCIOD PWM mode selection bit:PWM mode */
pwm2_trcmr = 1; /* PWM2 mode selection bit:PWM mode */
bfc_trcmr = 0; /* TRCGRC:General register */
bfd_trcmr = 0; /* TRCGRD:General register */
tob_trccr1 = 0; /* TRDIOB output level:"H" active */
toc_trccr1 = 0; /* TRDIOC output level:"H" active */
tod_trccr1 = 0; /* TRDIOD output level:"H" active */
eb_trcoer = 1; /* TRCIOB Pin Output disable */
ec_trcoer = 1; /* TRCIOC Pin Output disable */
ed_trcoer = 0; /* TRCIOD Pin Output enable */
pto_trcoer = 0; /* INT0 of Pulse output forced cutoff input disabled */
tck0_trccr1 = 1; /* Count Source Selection Bit:f2("001") */
tck1_trccr1 = 0;
tck2_trccr1 = 0;
cclr_trccr1 = 1; /* The TRC register clear at the compare match with TRCGRA */
trc = 0; /* The Count value of TRC is initialized to "0" */
trcgra = 0; /* 周期 */
trcgrd = 0; /* 翻转 */
trcier = 0x00; /* Disable interrupts ,ovie/imied/imiec/imieb/imiea */
// imiea_trcier=1; /* Enable imiea interrupt 使用TIMER C的中断*/
// trcic=7;
tstart_trcmr = 1; /* Start TRC Count */
}
文章评论(0条评论)
登录后参与讨论