#include "includes.h"
volatile uint32_t u32Timer0Cnt=20;
int32_t main(void)
{
uint32_t u32Timer0Cnt=0;
uint32_t TMR0_Callback;
//如果没有声明这个变量TMR0_Callback的话,编译到compiling DrvTIMER.c...,Target not created
DrvSYS_SelectIPClockSource(E_SYS_TMR0_CLKSRC,0);
DrvTIMER_Init();
/*using Timer0 periodic_mode ,the interval is set 2 tick/sec**/
DrvTIMER_Open(E_TMR0,2,E_PERIODIC_MODE);
/*install Callback function"call_back" and excute it when interrupt happen twice time*/
DrvTIMER_SetTimerEvent(E_TMR0, 2,(TIMER_CALLBACK)TMR0_Callback, 1);
/**Enable TIMER0 Interrupt*/
DrvTIMER_EnableInt(E_TMR0);
/*Start Counting*/
DrvTIMER_Start(E_TMR0);
/**Waiting for 10 times timer callbacks*/
while(u32Timer0Cnt <10);
/*Delay 4 ticks*/
DrvTIMER_Delay(E_TMR0,4);
/*Close TIMER0*/
DrvTIMER_Close(E_TMR0);
}
void TMR_Callback()
{
u32Timer0Cnt++;
}
其中<include.h>中的头文件有
#include <stdio.h>
#include "NUC1xx.h"
#include "variables.h"
#include "hw_config.h"
#include "Driver\DrvGPIO.h"
#include "Driver\DrvSYS.h"
#include <Driver\DrvTIMER.h>
是不是TMR0_Callback是一个寄存器,而在此之前都没有定义过 |