?? timer.c
字號:
/******************************************************
File name: timer.c
Description:
Current version: V1.00.00
Author: WangRD
The latest modified data:
Replacement version:V1.1
Author:WangRD
The latest modified data:2006-7-11 22:03
CPU type: M30263F8
Copyright Renesas System Solutions (Beijing) Co.,Ltd
******************************************************/
#include "timer.h"
#include "simbemfinput.h"
//2006-7-11 21:45
#ifdef F20MHz
const UINT_16 TA3VAL = 6250 - 1; // 20000000/32/100(Hz)
#else
const UINT_16 TA3VAL = 5000 - 1; // 16000000/32/100(Hz)
#endif
//end of 2006-7-11 21:45
void timer_TA3_ini(void)
{
STP_TA(3); /* stop ta3 */
ta3mr = 0x80; /* setting ta3 as timer mode, 32 division */
ta3 = TA3VAL; /* setting the reload value for ta3 */
//2006-7-11 21:45
ta3ic = 0x00; /* disable ta3 underflow interruption */
STA_TA(3); /* start ta3*/
//end of 2006-7-11 21:45
}
#ifdef F20MHz
const UINT_16 TB1VAL = 1000; //20000000/20000
#else
const UINT_16 TB1VAL = 800; //16000000/20000
#endif
void timer_TB1_ini(void)
{
STP_TB(1); /* stop tb1 */
tb1mr = 0x00; /* timer mode, no-division */
tb1 = TB1VAL - 1; /* setting the reload value for tb1 */
tb1ic = 0x07; /* 7-level interruption*/
STA_TB(1); /* start tb1 */
}
/*tb1 interrupt entry 50us */
extern void pwm_tujo_cal(void);/* BEMF sampling */
void timer_tb1(void)
{
// #ifdef DEBUG_SIM
// TIMEBASETEST;
// #endif
#ifndef EXTINT4kHz
#ifndef EXTINT4kHz_2
pwm_tujo_cal();
#endif
#endif
//#define SIM
#ifdef SIM
sim_posinfo();
#endif
// #ifdef DEBUG_SIM
// TIMEBASETEST;
// #endif
}
/* The following is no use now !*/
#ifdef EXTINT4kHz
void timer_TA0_ini(void)
{
STP_TA(0);
ta0mr = 0x80;
ta0 = 0xffff;
ta0ic = 0x00;
//STA_TA(0);
}
#endif
#ifdef EXTINT4kHz_2
void timer_TA0_ini(void)
{
STP_TA(0);
ta0mr = 0x80; // divided by 32, one-shot mode
ta0 = 0xffff;
ta0ic = 0x07;
}
void timer_TB0_ini(void)
{
STP_TB(0);
tb0mr = 0x80; // divided by 32, one-shot mode
tb0 = 0xffff;
tb0ic = 0x07;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -