cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
1,882 Views
Registered: ‎02-24-2016

Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

Hi,

 

I am working on data acquisition from the PL that is stored in BRAM. Once the data is doing being acquired, the PL triggers a PS interrupt that is used to send the data through USB.

 

My problem is that it works fine for the first two data send, but the third one is always followed by an instant fourth repeating the data. I basically have an interrupt that is triggered without the PL triggering it. I have my interrupt flag variable defined as volatile, I also tried to clear the interrupt properly but nothing works.

 

Any ideas?

 

Here is the necessary parts of the code that I have regarding this:

 

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xscugic.h"

#define ACQ_INTERRUPT 		XPAR_FABRIC_MODULE_0_DATA_ACQ_DONE_INTR

volatile u32 acquisitionDone = 0; // This is my interrupt flag

static int setup_interrupts(XScuGic *intc) 
{
	int status;
	XScuGic_Config *intc_config;

	intc_config = XScuGic_LookupConfig(INTC_DEVICE_ID);
	if (NULL == intc_config) 
	{
		return XST_FAILURE;
	}

	status = XScuGic_CfgInitialize(intc, intc_config, intc_config->CpuBaseAddress);
	if (status != XST_SUCCESS) 
	{
		return status;
	}

	Xil_ExceptionInit();

	/* Connect the GIC interrupt handler to the exception vector in the processor */
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
				    (Xil_ExceptionHandler)XScuGic_InterruptHandler,
				    intc);


	status = XScuGic_Connect(intc, ACQ_INTERRUPT,
			(Xil_InterruptHandler)AcqHandler,
			(void *) intc);
	if (status != XST_SUCCESS) 
	{
		return status;
	}

	XScuGic_SetPriorityTriggerType(intc, ACQ_INTERRUPT, 0x00, 0x03);

	status = XScuGic_Connect(intc, ACQ_INTERRUPT,
			(Xil_InterruptHandler)AcqHandler,
			(void *) intc);
	if (status != XST_SUCCESS) 
	{
		return status;
	}

	Xil_ExceptionEnable();

	return XST_SUCCESS;
}

void AcqHandler(void *CallbackRef)
{
    acquisitionDone = 1;
} int main() { XScuGic intc; // Set up and configure the interrupt system status = setup_interrupts(&intc); if (status != XST_SUCCESS) { xil_printf("ERROR: Unable to initialize interrupt system: %d\n\r", status); exit(1); } XScuGic_Enable(&intc, ACQ_INTERRUPT); while(1) { if(acquisitionDone == 1) { // Do the data sending through USB acquisitionDone = 0; } } }

 

Thanks!

 

Paul

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Contributor
Contributor
2,863 Views
Registered: ‎02-24-2016

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

Problem solved.

 

I changed my RTL code to only have the falling edge of the clock in the process list and have a falling_edge condition to read the state of the counter instead of having the counter in the process list. I guess the propagation and change of the counter state was not fast enough to behave effectively outside of simulation.

 

Thanks for the help!

 

Paul

View solution in original post

0 Kudos
5 Replies
Highlighted
Moderator
Moderator
1,803 Views
Registered: ‎10-06-2016

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

Hi @p.lerolland

 

What is not clear in this case is how are you generating your interrupt signal and how does it looks like. I mean are you controlling somehow the data acquisition?  Or you have a periodic sampling? 

 

The code in  a quick view seems to be correct.

 

Regards

Ibai


Ibai
Don’t forget to reply, kudo, and accept as solution.
0 Kudos
Highlighted
Contributor
Contributor
1,794 Views
Registered: ‎02-24-2016

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

Hi @ibaie,

 

Thank you for your help.

 

I have a RTL IP that generates an interrupt (data_acquisition_done_flag_sig) based on a counter. So basically, if my counter (Xilinx IP) is greater than value X, then set the value, else clear the value. I also have a reset counter signal to reset the counter when the value is greater than X+Y (so before the counter overflows).

 

Here is what my RTL code looks like :

 

 

-- Set clear counter flag when decimal value of count is greater than 6600
process (COUNT_IN) begin if(to_integer(unsigned(COUNT_IN)) >= 6600) then reset_flag_sig <= '1'; else reset_flag_sig <= '0'; end if; end process;

-- Set data_acquisition_done flag when decimal value of count is greater than 2600 (data is all stored in BRAM)
-- and the overflow_detection_output_flag is clear. (It is set once every two data acquisition)
process (COUNT_IN)
begin
    if ((to_integer(unsigned(COUNT_IN)) >= 2600) and (overflow_detection_output_sig = '0')) then
        data_acq_done_flag_sig <= '1';
    else
        data_acq_done_flag_sig <= '0';
    end if;
end process;

-- Toggling overflow_detection_output_sig every two data_acquisition
process(COUNT_IN)
begin
    if(to_integer(unsigned(COUNT_IN)) = 2552) then
        if(flag_of_sig = '0') then
            flag_of_sig <= '1';
            overflow_detection_output_sig <= not overflow_detection_output_sig;
        end if;
    else
        flag_of_sig <= '0';
    end if;
end process;

The clock for COUNT_IN (which is the output of the 32 bits counter) is at 400kHz (Fabric clock 1) and the fabric clock 0 is at 100MHz).

 

Every simulation that I ran looks good, the waveform meet the requirements.

 

I also tried to output the data_acq_done_flag_sig (inferred as an interrupt with EDGE_RISING sensitivity to connect to Zynq PL to PS interrupt) on a pin so I could scope it, but the other signals stop functioning when I do so.

 

Thanks!

 

Paul

 

0 Kudos
Highlighted
Contributor
Contributor
2,864 Views
Registered: ‎02-24-2016

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

Problem solved.

 

I changed my RTL code to only have the falling edge of the clock in the process list and have a falling_edge condition to read the state of the counter instead of having the counter in the process list. I guess the propagation and change of the counter state was not fast enough to behave effectively outside of simulation.

 

Thanks for the help!

 

Paul

View solution in original post

0 Kudos
Highlighted
987 Views
Registered: ‎05-05-2018

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

hi, i have same problem. i am using gpio. interrupt generates twice. is there any way that i can set gpio pin to detct only in raising edge? Set trigger is not working on my case.

0 Kudos
Highlighted
936 Views
Registered: ‎05-05-2018

Re: Interrupt - Unwanted double trigger every 3 interrupts

Jump to solution

got solution for this. just used a port as interrupt and connected it to interrupt controller. this made the job.

0 Kudos