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

📄 timer1.c

📁 2410一些基本试验的源码
💻 C
字号:
#include "2410addr.h"
#include "2410lib.h"
#include "timer.h"
int l=0;

void __irq timer1hander()
{
	ClearPending(BIT_TIMER1);
	l++;
	rTCON=(9<<8);
	Uart_Printf("The timer1hander is beginning\n");
}

void timer_int()
{
	ClearPending(BIT_TIMER1);
	
	rTCFG0=100;//prescaler=100
	rTCFG1=(1<<4);//1/4*PCLK,pclk=50MH
	//t=101*4/50000000=0.00000808s
	
	rTCON=(11<<8);
	rTCNTB1=24752;//T=24752*0.00000808s=0.2s
	
	rTCON=(9<<8);
	EnableIrq(BIT_TIMER1);
	
	Uart_Printf("The timer_int is beginning\n");	
}

int Main()
{
	SetClockDivider(1,1);//FLCK:HCLK:PCLK=1:2:4
	SetSysFclk(DFT_FCLK_VAL);//Fout=200MHZ
	Port_Init();
		
	Uart_Select(0);
	Uart_Init(0, UART_BAUD);
	Uart_Printf("The main is beginning\n");
	
	rGPFCON|=0x55ff;
	rGPFUP=0;
	rGPFDAT&=0x00ff;
	
	pISR_TIMER1=(unsigned)timer1hander;
	
	timer_int();
	
	//rGPBCON = rGPBCON & ~(3<<0)|(1<<1);//set GPB0 as tout0, pwm output


	while(1)
	{
		if(l==5)
		{
			rGPFDAT=~rGPFDAT;
			l=0;
		}
	}
}

⌨️ 快捷键说明

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