/************************************************************************
*函数原型: 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条评论)
登录后参与讨论