Project

General

Profile

Interrupt source code for DSP

Added by Stefan Krassin almost 10 years ago

Hi All,

I try to figure out how to serve an interrupt in the DSP code and how to register an ISR for a FPGA interrupt.
How can I register an interrupt system in the DSP code (interrupt from FPGA --> execute ISR)? Could anyone provide me a simple example code for this?
I don't understand the interrupt example code form CCL.

Thanks
Stefan


Replies (7)

RE: Interrupt source code for DSP - Added by stefan nielsen almost 10 years ago

Hi Stefan

Have you seen this post "GPIO interrupt in MityOMAP-L138F" it might help you. Im also looking for help with setting up an FPGA gpio interrupt.

/stefan nielsen

RE: Interrupt source code for DSP - Added by stefan nielsen almost 10 years ago

Hi again Stefan

im trying to get an FPGA interrupt working on the industrual I/O . ive tried both
mpGpio_input->SetISRCallback and tcDspInterruptDispatch::register_isr_callback but not with any luck.
Im still unsure which one of them i need to use could somebody please help. But anyway this might give an idea (Its just not working for me..)

im using J702 pin 3 as input/interrupt pin(bank0,offset0 from core FPGA_GPIO_INPUT_BASE_ADDRESS)
code snips:
#define FPGA_BASE_ADDRESS                0x66000000
#define FPGA_GPIO_INPUT_BASE_ADDRESS 0x66000100
typedef int Arg;
char tmp[80];
tcDspFirmware::set_firmware_base((void *)FPGA_BASE_ADDRESS);
tcDspInterruptDispatch::set_hw_interrupt_level(1,8);
tcDspFirmware::set_vector_enable(1, 0x0001, TRUE);
tcDspFirmware::get_version_info((void*)FPGA_GPIO_INPUT_BASE_ADDRESS, &aCoreVer);
int mnIntLevel = aCoreVer.ver0.bits.level;
int mnIntVector = aCoreVer.ver0.bits.vector;
sprintf(tmp,"Adr: %#010x Interrupt lvl:%d, vector.%d \n",FPGA_GPIO_INPUT_BASE_ADDRESS,mnIntLevel,mnIntVector);
debugPrint(tmp);//function from HelloWorldDSP project
tcDspInterruptDispatch::register_isr_callback(mnIntLevel, mnIntVector, myIsr, (Arg)1);
mpGpio_input = new tcDspFpgaGpio((void*)FPGA_GPIO_INPUT_BASE_ADDRESS);//GPIO
mpGpio_input->ConfigurePin(0,0,0,0,1,0);
mpGpio_input->SetISRCallback(0,0,MyISR,NULL);// Second ISR
void MyISR(tcGpio *apThis, unsigned int Bank, unsigned int Offset, void *apUser)
{
char tmp[80];
sprintf(tmp,"********** MyISR Bank:%d, Offset:%d * \n", Bank,Offset);
debugPrint(tmp);
lpApp->TogglePin_16();
}
int myIsr(Arg ahMyObject)
{
debugPrint("My ISR");//function from HelloWorldDSP project
return (0);
}
FPGA code snip:
Instantiations:
constant CORE_BASE_MODULE   : integer := 0;
constant CORE_GPOUT_MODULE : integer := 1;
constant CORE_GPIN_MODULE : integer := 2;
constant CORE_GPOUT_IRQ_VECTOR : integer := 0;
constant CORE_GPOUT_IRQ_LEVEL : integer := 1;
constant CORE_GPIN_IRQ_VECTOR  : integer := 1;
constant CORE_GPIN_IRQ_LEVEL : integer := 1;
gpio1 : gpio
generic map (
NUM_BANKS => 1,
NUM_IO_PER_BANK => 4
)
Port Map (
clk => ema_clk,
i_ABus => addr_r,
i_DBus => edi_r,
o_DBus => edo_arm(CORE_GPOUT_MODULE),
i_wr_en => wr_r,
i_rd_en => rd_r,
i_cs => arm_cs5_r(CORE_GPOUT_MODULE),
o_irq => irq_map(CORE_GPOUT_IRQ_LEVEL)(CORE_GPOUT_IRQ_VECTOR),
i_ilevel => conv_std_logic_vector(CORE_GPOUT_IRQ_LEVEL, 2),
i_ivector => conv_std_logic_vector(CORE_GPOUT_IRQ_VECTOR, 4),
i_io => s_gpout, -- GPIO read values. Loop back output values so they can be read from software.
t_io => open, -- Do not care about direction of GPIOs
o_io => s_gpout, -- GPIO write values
i_initdir => "1111", -- default to all outputs
i_initoutval => "0000"
);
gpio2 : gpio
generic map (
NUM_BANKS => 1,
NUM_IO_PER_BANK => 2
)
Port Map (
clk => ema_clk,
i_ABus => addr_r,
i_DBus => edi_r,
o_DBus => edo_arm(CORE_GPIN_MODULE),
i_wr_en => wr_r,
i_rd_en => rd_r,
i_cs => arm_cs5_r(CORE_GPIN_MODULE),
o_irq => irq_map(CORE_GPIN_IRQ_LEVEL)(CORE_GPIN_IRQ_VECTOR),
i_ilevel => conv_std_logic_vector(CORE_GPIN_IRQ_LEVEL, 2),
i_ivector => conv_std_logic_vector(CORE_GPIN_IRQ_VECTOR, 4),
i_io(0) => i_J702_3,
i_io(1) => i_J702_4,
t_io => open,
o_io => open,
i_initdir => "00", -- default to all inputs
i_initoutval => "00"
);

RE: Interrupt source code for DSP - Added by Michael Williamson almost 10 years ago

For the GPIO, you should only use SetISRCallback(). The tcDspFpgaGpio class will call the register_isr_callback() method for you.

Are you using the DSP/BIOS MityDSP-L138 Platform.tci file as a template for you BIOS? You need to ensure that the BIOS interrupt dispatcher is enabled for the GPIO pins used.

Have you verified that your I/O input pin is toggling by polling on the state and seeing it transition? Is it possible you have a UCF issue on your FPGA build?

-Mike

RE: Interrupt source code for DSP - Added by stefan nielsen almost 10 years ago

Hi

(Are you using the DSP/BIOS MityDSP-L138 Platform.tci file as a template for you BIOS? )
yes im using it, from the HelloWorldDSP example.

(You need to ensure that the BIOS interrupt dispatcher is enabled for the GPIO pins used)
How do i check that ?

(Have you verified that your I/O input pin is toggling by polling on the state and seeing it transition?)
ive used PinVal3 = mpGpio_input->GetPinValue(0,0); and then a print out of PinVal3 and it toggles..

/stefan

RE: Interrupt source code for DSP - Added by Stefan Krassin almost 10 years ago

Are you sure that the baseaddress for the input gpio is 0x66000100? How long is your address vector from the EMIFA IF module to the GPIO?
If you didn't change anything the vector should have a size of 6 bits.
That means that your baseaddress for the input gpio should be 0x66000080.

RE: Interrupt source code for DSP - Added by stefan nielsen almost 10 years ago

Hi Stefan

i Have two FPGA GPIO cores one at 0x66000080(output) and one at 0x66000100(input). Anyway with some help from Michele Capena i got the above code to run. I just removed this line tcDspFirmware::set_vector_enable(1, 0x0001, TRUE); once it was removed i got my interrupts...

RE: Interrupt source code for DSP - Added by Stefan Krassin almost 10 years ago

I also got the SW to run. But I have to use the set_vector_enable() function. This function enables the gpio-input interrupt in the base module.
Below you can find my code:

I have changed my address vector to 10 bits.

tcDspFpgaGpio *GpioIn  = new tcDspFpgaGpio((void*)0x66000800);
tcDspFpgaGpio *GpioOut = new tcDspFpgaGpio((void*)0x66001000);

Route the interrupt IRQ1 from the FPGA to the HWI no 10 of the DSP.
tcDspInterruptDispatch::set_hw_interrupt_level(1,10);

Enable the interrupt source in the base module.
GPIO_IN_IRQ_LEVEL = 1
GPIO_IN_IRQ_VECTOR = 0
tcDspFirmware::set_firmware_base ((void*)0x66000000);
tcDspFirmware::set_vector_enable (1, 0x0001,true);

I configured bit0 of my input gpio to be rising edge sensitive for an interrupt.
And set the ISR for this interrupt source.
GpioIn->ConfigurePin(0,i,false,0,true,false);
GpioIn->SetISRCallback(0,i,MyISR,NULL);

And the ISR looks like this:
void MyISR(tcGpio *apThis, unsigned int Bank, unsigned int Offset, void *apUser)
{
    char debug1[] = "In ISR !!!\n";
    debugPrint(debug1);

    // ISR code ...
}

Hope this helps anyone in future!

Stefan Krassin

    (1-7/7)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)