码迷,mamicode.com
首页 > 其他好文 > 详细

ZYNQ XC7Z020平台PPI SCUTimer中断示例程序

时间:2021-01-06 11:51:20      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:seconds   source   zynq   cep   unique   gic   start   except   elf   

static void TimerInterruptHandler(void * CallBackRef)
{
    static int sec = 0;
    printf("%d Seconds\n", sec++);
    XScuTimer * TimerInstPtr = (XScuTimer *)CallBackRef;
    XScuTimer_ClearInterruptStatus(TimerInstPtr);
}

int main(void)
{
    init_platform();
// Lookup the Timer configuration based on the unique device ID XScuTimer_Config * TimerConfigPtr; TimerConfigPtr = XScuTimer_LookupConfig(XPAR_XSCUTIMER_0_DEVICE_ID); // Initialize a specific timer instance/driver XScuTimer XScuTimerInst; XScuTimer_CfgInitialize(&XScuTimerInst, TimerConfigPtr, TimerConfigPtr->BaseAddr); // Run a self-test on the timer XScuTimer_SelfTest(&XScuTimerInst); //--------------------------------------------------------------------------- // Timer configure //--------------------------------------------------------------------------- // Write to the timer load register XScuTimer_LoadTimer(&XScuTimerInst, 0x13D92D3F); // Enable auto-reload mode XScuTimer_EnableAutoReload(&XScuTimerInst); // Start timer XScuTimer_Start(&XScuTimerInst); //--------------------------------------------------------------------------- // Interrupt Controller initialization //--------------------------------------------------------------------------- XScuGic XScuGicInst; XScuGic_Config *XScuGic_Config_ptr; XScuGic_Config_ptr = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID); // CfgInitialize a specific interrupt controller instance/driver XScuGic_CfgInitialize(&XScuGicInst, XScuGic_Config_ptr, XScuGic_Config_ptr->CpuBaseAddress); //--------------------------------------------------------------------------- // Interrupt system setup //--------------------------------------------------------------------------- // Makes the connection between the Id of the exception source and the associated Handler Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, &XScuGicInst); // Enable Exceptions Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ); //--------------------------------------------------------------------------- // Register Interrupt Handler //--------------------------------------------------------------------------- // Makes the connection between the Int_Id of the interrupt source and the associated handler XScuGic_Connect(&XScuGicInst, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler)TimerInterruptHandler, (void *)&XScuTimerInst); //--------------------------------------------------------------------------- // Enable Timer interrupt in the controller //--------------------------------------------------------------------------- // Enable the Timer interrupt XScuTimer_EnableInterrupt(&XScuTimerInst); XScuGic_Enable(&XScuGicInst, XPAR_SCUTIMER_INTR); printf("GIC SCUTimer ...\n"); while(1); cleanup_platform(); return 0; }

 

ZYNQ XC7Z020平台PPI SCUTimer中断示例程序

标签:seconds   source   zynq   cep   unique   gic   start   except   elf   

原文地址:https://www.cnblogs.com/lyuyangly/p/14224461.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!