📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
static U32 TimerCnt=0;
static int LedStatus=0;
void __irq Timer_Tick(void)
{
rI_ISPC=BIT_TIMER3;
if(TimerCnt++ == 10) {
TimerCnt=0;
Led_Display(LedStatus);
LedStatus=(~(LedStatus)&0x7);
Uart_Printf("\nTIMER interrupt... ");
}
}
void Timer_Init(void)
{
/*
* Timer Clock Frequency = MCLK/pre/mux
*/
rTCFG0=0x00000f00; //dead zone=0,pre2=0,pre1=0xf,pre0=0
rTCFG1=0x00001000; //all interrupt,mux5=1/2,mux2=1/2,mux3=1/4,mux2=1/2,mux1=1/2,mux0=1/2
rTCNTB3=0xc350; //(1/(60MHz/4/15))*0xc350=50ms
//(1/(60MHz/4/15))*0x4320=20ms
rTCMPB3=0x0;
rTCON=0x0020000; //update T3
rTCON=0x0090000; //T3=auto reload,start
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
pISR_TIMER3=(unsigned)Timer_Tick;
rINTMSK=BIT_GLOBAL;
rINTMSK=~(BIT_GLOBAL|BIT_TIMER3); //start timer INT
}
void Main(void)
{
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
Uart_Init(0,57600);
Delay(10);
Uart_Select(0); //Select UART0
Led_Display(0x07);
Uart_Printf("\nSXHC44B0 TIMER INTERRUPT ");
Uart_Printf("\n定时器中断DEMO");
Timer_Init();
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -