|
楼主 |
发表于 2011-3-2 09:35:05
|
显示全部楼层
我自己解决好了 传个可以用的程序
#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_TIMER0;
TimerCnt++;
if(TimerCnt>19) {
TimerCnt=0;
Led_Display(LedStatus);
LedStatus=(~(LedStatus)&0x7);
//Uart_Printf("\nTIMER interrupt... ");
}
else ;
return ;
}
void Timer_Init(void)
{
/*
* Timer Clock Frequency = MCLK/pre/mux
*/ rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
rINTMSK=~(BIT_GLOBAL|BIT_TIMER0);//start timer INT
pISR_TIMER0=(U32)Timer_Tick;
rTCFG0=0x0000000f; //dead zone=0,pre2=0,pre1=0xf,pre0=0
rTCFG1=0x00000001; //all interrupt,mux5=1/2,mux4=1/2,mux3=1/4,mux2=1/2,mux1=1/2,mux0=1/2
rTCNTB0=0xc350; //(1/(60MHz/4/15))*0xc350=50ms
//(1/(60MHz/4/15))*0x4320=20ms
rTCMPB0=0x0;
rTCON=0x0000003; //update T0
rTCON=0x0000009;//0x00B0000; //T3=auto reload,start
//rTCON=0x00;
// while(1);
// rINTMSK=BIT_GLOBAL;
}
void Main(void)
{
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
// Uart_Init(0,57600);
Delay(10);
// Uart_Select(0); //Select UART0
Led_Display(1);
// Uart_Printf("\nFS44B0X TIMER ");
// Uart_Printf("\n定时器中断DEMO");
Timer_Init();
while(1);
} |
|