Не получается настроить таймер в SDK. Не могу понять почему не работает. Может кто поможет где косяк?
Код
#define TIMER_LOAD_VALUE (0xF8000000)
#define TIMER_DEVICE_ID XPAR_XSCUTIMER_0_DEVICE_ID
#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
#define TIMER_IRPT_INTR XPAR_SCUTIMER_INTR
static XScuTimer Timer;//timer
static XScuGic Intc; //GIC
static void SetupInterruptSystem(XScuGic *GicInstancePtr,XScuTimer *TimerInstancePtr, u16 TimerIntrId);
void TimerStart(void)
{
XScuTimer_LoadTimer(&Timer,TIMER_LOAD_VALUE);
XScuTimer_Start(&Timer);
xil_printf("Timer run..\n\r");
}
void TimerInit(void)
{
XScuTimer_Config *TMRConfigPtr;
// Инициализация
TMRConfigPtr = XScuTimer_LookupConfig(TIMER_DEVICE_ID);
XScuTimer_CfgInitialize(&Timer,TMRConfigPtr,TMRConfigPtr->BaseAddr);
XScuTimer_SelfTest(&Timer);
// Загрузка таймера
XScuTimer_LoadTimer(&Timer,TIMER_LOAD_VALUE);
// Set up the Timer interrupt
SetupInterruptSystem(&Intc,&Timer,TIMER_IRPT_INTR);
xil_printf("Timer config..\n\r");
// Запуск таймера
//XScuTimer_Start(&Timer);
//xil_printf("Timer run..\n\r");
}
static void TimerIntrHandler(void *CallBackRef)
{
XScuTimer *TimerInstancePtr = (XScuTimer *) CallBackRef;
XScuTimer_ClearInterruptStatus(TimerInstancePtr);
//XScuTimer_LoadTimer(&Timer,TIMER_LOAD_VALUE);
//user code -->>
xil_printf("****Timer Event!!!!!!!!!!!!!****\n\r");
//<<--
//XScuTimer_Start(&Timer);
}
static void SetupInterruptSystem(XScuGic *GicInstancePtr,XScuTimer *TimerInstancePtr, u16 TimerIntrId)
{
XScuGic_Config *IntcConfig; //GIC config
Xil_ExceptionInit();
//initialise the GIC
IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
XScuGic_CfgInitialize(GicInstancePtr, IntcConfig,
IntcConfig->CpuBaseAddress);
//connect to the hardware
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler,
GicInstancePtr);
Xil_ExceptionEnable();
//set up the timer interrupt
XScuGic_Connect(GicInstancePtr, TimerIntrId,
(Xil_ExceptionHandler)TimerIntrHandler,
(void *)TimerInstancePtr);
//enable the interrupt for the Timer at GIC
XScuGic_Enable(GicInstancePtr, TimerIntrId);
//enable interrupt on the timer
XScuTimer_EnableInterrupt(TimerInstancePtr);
// Enable interrupts in the Processor.
Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);
}