新闻  |   论坛  |   博客  |   在线研讨会
r8c\2k 2l的定时器C PWM模式初始化程序
renesasrulz | 2009-12-26 12:08:03    阅读:1467   发布文章

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

初始化程序仅供参考!

/************************************************************************************
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 */

}

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
来自瑞萨单片机论坛(www.renesas-mcu.com)的经典文章。仅供大家参考,版权归作者所有。
推荐文章
最近访客