原创 R8C\2K 2L定时器B的定时模式初始化设置

2011-2-25 14:20 1680 4 4 分类: MCU/ 嵌入式
来源:瑞萨单片机论坛
/************************************************************************
*函数原型: Timer_RB_Init
*功能 : 初始化RB
************************************************************************/
void Timer_RB_Init(void)
{
tstart_trbcr = 0;      /* Stop Timer RB operation */
while(tcstf_trbcr != 0);
trbic = 0x00;       /* Disable Timer RB Interrupt */
tstop_trbcr = 1;      /* The TRBPRE and TRBPR registers are initialized */
           /* The TSTART and TCSTF bits in the TRBCR register are initialized too. */
/****************************************************************/
/* Period between underflows : 20MHz * f2 * 200 * 50 = 1ms */
trbpre = 200-1;       /* Set (200 - 1) in TRBPRE register */
trbpr = 125-1;       /* Set (50 - 1) in TRBPR register */
/****************************************************************/
topl_trbioc = 0;      /* Set to "0" in timer mode */
tocnt_trbioc = 0;      /* Set to "0" in timer mode */
inostg_trbioc = 0;      /* Set to "0" in timer mode */
inoseg_trbioc = 0;      /* Set to "0" in timer mode */
tmod0_trbmr = 0;      /* Set to "00" in timer mode */
tmod1_trbmr = 0;
twrc_trbmr = 0;       /* Write to reload register and counter */
tck0_trbmr = 1;                     /* Select "f2" in Count Source */
tck1_trbmr = 1;
tckcut_trbmr = 0;      /* Provides count source */
trbic=1;              /*中断级别*/
tstart_trbcr = 1;      /* Start Timer RB operation */
while(tcstf_trbcr != 1);
}

文章评论0条评论)

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