⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer0.c

📁 wince5.0ads2410arm9源代码希望对大家有帮助
💻 C
字号:
#include "2410addr.h"
#include "2410lib.h"
#include "timer.h"

void __irq timer0Handler(void);

void INT_Timer_Initialize(void)
{
	
 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 /*                                                                 */
 /*     Fout(s)=[(prescaler+1)*(TCNTB+1)]/[pclk*divider]=40ms       */
 /*                                                                 */
 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	rTCFG0=0x64; 	//prescaler0 100
	rTCFG1=0x01; 	//divide value 1/4
	rTCNTB0=5000;	//TCNTB=5000
	rTCON=0x0a;  	//auto load, invert off, manual update, stop timer
	/*INTIALIZE THE INTERRUPT*/
	rINTMOD=0x0;  	//all irq
	rINTMSK=0xffffffff; 	 //disable all interrupt source
	rINTSUBMSK=0xffff; 		//disable all sub interrupt source
}


/* open the interrupt timer0 and eint0 */
void ENABLE_INTERRUPT(void)
{
	rINTMSK=~(BIT_TIMER0);
	rTCON=0x09;
}


int Main()
{
             
    SetClockDivider(1, 1);
	SetSysFclk(DFT_FCLK_VAL);
	Port_Init();
		
	Uart_Select(0);
	Uart_Init(0, UART_BAUD);
    
    //timer0初始化
    INT_Timer_Initialize();	
	
	//建立中断向量表
	pISR_TIMER0=(unsigned)timer0Handler;
	
	//开中断
	ENABLE_INTERRUPT();
	
	Uart_Printf("the main is running\n");
 
    while(1);
   //{
     //Uart_Printf("the main is running\n");
     //Delay(1000);
   //}
}


void __irq timer0Handler(void)
{
    printf("timer0 is running.\n");
    ClearPending(BIT_TIMER0);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -