cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rubzi
Visitor
Visitor
1,300 Views
Registered: ‎01-03-2019

Interrupt Issue - Not able to control triggering or write to registers (continuous triggering)

Hi folks, 

I am running an application design on Zybo Zynq-7000, where I am struggling to work with my GIC. 

I have tried simple designs to verify if I can get interrupts to work but still not going anywhere. In my interrupt handler I set a GPIO high and clear it at the end of my interrupt handler. What I observe, is that even if the input trigger signal to my PS (FIQ, IRQ or IRQ_F2P - tried it all) is high only once, my ISR triggers continuously (see attached scope image, yellow ISR called and Blue is trigger input).

Obvious reason could be the setting of "void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id, u8 Priority, u8 Trigger)", but the last argument does not change my triggering part what so ever. So I ventured into writing directly into the registers using "B.24 Application Processing Unit (mpcore) Zynq-7000 SoC UG585 (v1.12.2) July 1, 2018 ), But I am not allowed to write into e.g. ICDICFR1 or ICDICFR4 or various registers to set up my interrupts. This I test be below statement:

//Interrupt Configuration Register 1
// Enable IRQ and FIQ to be low-level active and edge sensitive (triggers on edge)
addr=0xF8F00000+0x00001C04;
reg=0xFFFF0000;
xil_printf("ICDICFR1 Register %08x\n\r", XScuGic_ReadReg(IRQ_DIST, addr));
XScuGic_WriteReg(IRQ_DIST, addr, reg); // SCU Control Register Enable pg 1431
xil_printf("ICDICFR1 Register %08x\n\r", XScuGic_ReadReg(IRQ_DIST, addr));

I also tried to observe if registers are changing in debug mode, but I am unable to write to them. 

I use Vivado 2019.1, and therefore not able to load project https://www.xilinx.com/support/answers/50572.html. I also followed thread "https://forums.xilinx.com/t5/Embedded-Processor-System-Design/PL-to-PS-interrupt/td-p/540029" and others bsp examples, but nothing explains what I am observing.

My simple main file implementation where my timer is set to 25000000 counters before output at 50MHz clock Freq which gives two ticks per second:

/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xil_io.h"
#include "xil_exception.h"
#include "xparameters.h"
#include "xil_cache.h"
#include "xil_printf.h"
#include "xil_types.h"
#include "xscugic.h"


#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID

#define XGPIOPS_IRQ_TYPE_EDGE_RISING 0 /**<Interrupt on Rising edge */
#define XGPIOPS_IRQ_TYPE_EDGE_FALLING 1 /**<Interrupt Falling edge */
#define XGPIOPS_IRQ_TYPE_EDGE_BOTH 2 /**<Interrupt on both edges */
#define XGPIOPS_IRQ_TYPE_LEVEL_HIGH 3 /**<Interrupt on high level */
#define XGPIOPS_IRQ_TYPE_LEVEL_LOW 4 /**<Interrupt on low level */

static XScuGic Intc; // Interrupt Controller Driver

// Function Prototypes
void initGIC();
void ISR(); // Interrupt Service Routine

// Global
u32 tick=0;

int main()
{
init_platform();
initGIC();
while(1)
{
//printf("Tick: %u\n\r",(unsigned)tick);
}

cleanup_platform();
return 0;
}

void initGIC()
{
//GIC config
XScuGic_Config *IntcConfig;
Xil_ExceptionInit();

//initialize the GIC
IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
XScuGic_CfgInitialize(&Intc, IntcConfig,
IntcConfig->CpuBaseAddress);

//connect to the hardware
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)ISR, &Intc);

XScuGic_SetPriorityTriggerType(&Intc, XPAR_FABRIC_FIT_TIMER_0_INTERRUPT_INTR,0xa0, XGPIOPS_IRQ_TYPE_EDGE_RISING);

//set up the timer interrupt
XScuGic_Connect(&Intc, XPAR_FABRIC_FIT_TIMER_0_INTERRUPT_INTR,
(Xil_ExceptionHandler)ISR,
NULL);
//enable the interrupt for the Timer at GIC
XScuGic_Enable(&Intc, XPAR_FABRIC_FIT_TIMER_0_INTERRUPT_INTR);
Xil_ExceptionEnable();
}

void ISR(void *callbackref)
{
printf("Tick: %u\n\r",(unsigned)tick);
tick++;
}

 

I hope you can help or guide me to an answer. Been struggling with interrupts for days and it have been interrupting my sleep at nights!! 

 

WBR

Capture.PNG
thumbnail_20191025_131716.jpg
5 Replies
yunusyurtturk
Visitor
Visitor
1,014 Views
Registered: ‎12-07-2019

Struggling from same problem. Anyone can help?

0 Kudos
rubzi
Visitor
Visitor
1,000 Views
Registered: ‎01-03-2019

Hi, 

I managed to get it running by using Core0_nFIQ. 

 

Your PS code should be:

xil_printf("\r\n\nInitialising system\r\n");

int status;

xil_printf(" Initialising Global Interrupt Controller...");
XScuGic_Config *gic_configuration = XScuGic_LookupConfig(GIC_ID);
status = XScuGic_CfgInitialize(&gic_handle, gic_configuration, gic_configuration->CpuBaseAddress);
xil_printf(status == XST_SUCCESS ? "done\r\n" : "failed\r\n");

xil_printf(" Connecting interrupt handler...............");
status = XScuGic_Connect(&gic_handle, INTERRUPT_ID, (Xil_InterruptHandler)ISR, NULL);
xil_printf(status == XST_SUCCESS ? "done\r\n" : "failed\r\n");

xil_printf(" Enabling interrupts........................");
XScuGic_Enable(&gic_handle, INTERRUPT_ID);
xil_printf("done\r\n");

XScuGic_SetPriorityTriggerType(&gic_handle, INTERRUPT_ID, INTERRUPT_PRIORITY, 3);

xil_printf(" Initialising exceptions....................");
Xil_ExceptionInit();
Xil_ExceptionRegisterHandler(5,ISR, NULL);
Xil_ExceptionEnable();
xil_printf("done\r\n");

xil_printf("System initialised\r\n\n");

and with

#define GIC_ID XPAR_SCUGIC_SINGLE_DEVICE_ID
#define INTERRUPT_ID XPS_FPGA0_INT_ID
#define INTERRUPT_PRIORITY 0xA0

See also attached "bd.png"

Hope this helps

 

bd.png
0 Kudos
yunusyurtturk
Visitor
Visitor
994 Views
Registered: ‎12-07-2019

Hi. What did you change from the first time?
I set interrupt trigger type as your code, not changing any priority and interrupt no is 61.
0 Kudos
rubzi
Visitor
Visitor
925 Views
Registered: ‎01-03-2019

Hi,
You should use no. 28 for nFIQ CPU0, 31 for IRQ and 61 for Normal IRQ.
Try with ID 28
0 Kudos
sabankocal
Voyager
Voyager
860 Views
Registered: ‎08-02-2019

Hi @yunusyurtturk ,

I strongly recommend to you, instead of awaring IRQ numbers, you should find correct IRQ alias in xparameters.h or xparameters_ps.h

Of course, after new bit file generation:

  • you need to export hardware 
  • Re-generate BSP sources by right clicking on your bsp project.

In files, I mentioned before, you can find related #define aliases like that:

/* Private Peripheral Interrupts (PPI) */
#define XPS_GLOBAL_TMR_INT_ID		27U	/* SCU Global Timer interrupt */
#define XPS_FIQ_INT_ID			28U	/* FIQ from FPGA fabric */
#define XPS_SCU_TMR_INT_ID		29U	/* SCU Private Timer interrupt */
#define XPS_SCU_WDT_INT_ID		30U	/* SCU Private WDT interrupt */
#define XPS_IRQ_INT_ID			31U	/* IRQ from FPGA fabric */

If you use IRQ_F2P[15:0] or multiple of them, it would more difficult to find related IRQ number. 

 

Saban

<------------------------------------------------------------------------------>

if(solves_problem) mark_as_solution <= 1 else if(helpful) Kudo <= Kudo + 1

 

<--- If reply is helpful, please feel free to give Kudos, and close if it answers your question --->
0 Kudos