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

2011-2-25 14:20 1335 2 2 分类: MCU/ 嵌入式
来源:瑞萨单片机论坛
/************************************************************************
*函数原型: Timer_RA_Init
*功能 : 初始化RA
************************************************************************/
void Timer_RA_Init(void)
{
tstart_tracr = 0;      /* Stop Timer RA operation */
while(tcstf_tracr != 0);
traic = 0x00;       /* Disable Timer RA Interrupt */
tstop_tracr = 1;      /* The TRAPRE and TRA registers are initialized */
/*****************************************************/
/* Period between underflows : 40MHz * 4 * 100 * 50 = 1ms */
trapre = 100-1;       /* Set (100 - 1) in TRAPRE register */
tra = 50-1;        /* Set (100 - 1) in TRA register */
/*****************************************************/
tedgsel_traioc = 0;      /* Set to "0" in timer mode */
topcr_traioc = 0;      /* Set to "0" in timer mode */
//toena_traioc = 0;      /* Set to "0" in timer mode */
tipf0_traioc = 0;      /* Set to "0" in timer mode */
tipf1_traioc = 0;      /* Set to "0" in timer mode */
tmod0_tramr = 0;      /* Set to "000" in timer mode */
tmod1_tramr = 0;
tmod2_tramr = 0;
tck0_tramr = 0;               /* Select "fOCO" in Count Source */
tck1_tramr = 1;
tck2_tramr = 0;
tckcut_tramr = 0;      /* Provides count source */
traic=2;/*中断级别*/
tstart_tracr = 1;      /* Start Timer RA operation */
while(tcstf_tracr != 1);
}

文章评论0条评论)

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