原创 r8c\2k 2l的定时器C PWM模式初始化程序

2011-2-25 14:19 1601 3 3 分类: MCU/ 嵌入式
来源:瑞萨单片机论坛
初始化程序仅供参考! 

/************************************************************************************ 
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条评论)

登录后参与讨论
我要评论
0
3
关闭 站长推荐上一条 /2 下一条