Hello!
I'm using the MicroZed 7010 board, with Xilinx SDK 2015.4.
I'm trying to write a simple C code that will flash the LED when a push-button interrupt occurs.
The status readings all report success, but when I press the button, nothing happens... What am I missing?
BTW, I saw the famous Adam Taylor’s MicroZed Chronicles blog:
I have downloaded and tried his code - it doesn't work either!
I would be happy to get help with this. Thank you all!
my code goes as follows:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "platform.h"
#include "xgpio.h"
#include "xgpiops.h"
#include "xparameters.h"
#include "xstatus.h"
#include "Xscugic.h"
#include "xil_exception.h"
static XGpioPs my_Gpio;
static XScuGic my_Gic;
static void USR_button_ISR(void *CallBackRef);
int main()
{
init_platform();
XGpioPs_Config *GPIO_Config;
GPIO_Config = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
int status;
status = XGpioPs_CfgInitialize(&my_Gpio, GPIO_Config, GPIO_Config->BaseAddr);
if (status == XST_SUCCESS)
printf("XGpioPs configuration successful! \n\r");
else
printf("XGpioPs configuration failed! \n\r");
XGpioPs_SetDirectionPin(&my_Gpio, 47, 1); // board LED, output
XGpioPs_SetOutputEnablePin(&my_Gpio, 47, 1);
XGpioPs_SetDirectionPin(&my_Gpio, 51, 0); // USR button, input
XScuGic_Config *Gic_Config;
Gic_Config = XScuGic_LookupConfig(XPAR_PS7_SCUGIC_0_DEVICE_ID);
status = XScuGic_CfgInitialize(&my_Gic, Gic_Config, Gic_Config->CpuBaseAddress);
if (status == XST_SUCCESS)
printf("GIC configuration successful! \n\r");
else
printf("GIC configuration failed! \n\r");
Xil_ExceptionInit();
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XScuGic_InterruptHandler, &my_Gic);
status = XScuGic_Connect(&my_Gic, XPS_GPIO_INT_ID, (Xil_ExceptionHandler)USR_button_ISR, (void *)&my_Gic);
if (status == XST_SUCCESS)
printf("Interrupt handler connection successful! \n\r");
else
printf("Interrupt handler connection failed! \n\r");
XGpioPs_SetIntrTypePin(&my_Gpio, 51, XGPIOPS_IRQ_TYPE_EDGE_RISING);
//XGpioPs_SetCallbackHandler(&my_Gpio, (void *)&my_Gpio, (XGpioPs_Handler)USR_button_ISR);
XGpioPs_IntrEnablePin(&my_Gpio, 51);
XScuGic_Enable(&my_Gic, XPS_GPIO_INT_ID);
Xil_ExceptionEnable();
printf("waiting...\n");
while (1)
{
}
cleanup_platform();
return 0;
}
static void USR_button_ISR(void *CallBackReff)
{
XGpioPs_WritePin(&my_Gpio, 47, 1);
sleep(5);
XGpioPs_WritePin(&my_Gpio, 47, 0);
}