реклама на сайте
подробности

 
 
> Zynq Timer, Настройка Zynq Timer
Kolia
сообщение Dec 8 2015, 16:13
Сообщение #1


Частый гость
**

Группа: Свой
Сообщений: 188
Регистрация: 28-09-06
Из: Minsk
Пользователь №: 20 762



Не получается настроить таймер в 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);
}
Go to the top of the page
 
+Quote Post

Сообщений в этой теме


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 22nd July 2025 - 20:46
Рейтинг@Mail.ru


Страница сгенерированна за 0.01374 секунд с 7
ELECTRONIX ©2004-2016