Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

IRQ from PIO Not working.. Please help, very detailed

Hello i made a wrapper that does that:

always@(posedge rdclk)
begin
    contador <= contador +1;
    valid <= 0;
    //rdreq <= 1;
    wrreq <= 1;
    wrclk <= 0;
        if(contador == 50000000) //1segundo
        begin
            contador <= 0;
            data_in <= data_in + 1;
            wrclk <=1;
        end
    if (usedw_r==1)
        valid <= 1;
    
end

I am exporting this valid signal like that in my SOPC:


//fifo
                      .valid_from_the_fifowrapper_0  (valid),
                      .in_port_to_the_pio_0          (valid),

So my code generates the "1" and it goes inside the PIO.

But it does not work, why? What configuration do i need to make this work?? This is my C code:


int main()
{
// Enable all 4 button interrupts.
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_0_BASE, 0xf);
// Reset the edge capture register.
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE, 0x0);
// Register the interrupt handler.
alt_irq_register( PIO_0_IRQ,&edge_capture, handle_button_interrupts );
alt_irq_enable_all;
printf("loop start");
while(1)
{
    usleep(100000);
    printf("---- %i ---\n",led);
}
return 0;
}

And this function..


static void handle_button_interrupts(void* context, alt_u32 id)
{
// Cast context to edge_capture&#39;s type. It is important that this be
// declared volatile to avoid unwanted compiler optimization.
//
volatile int* edge_capture_ptr = (volatile int*) context;
// Store the value in the Button&#39;s edge capture register in *context.
*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE);
// Reset the Button&#39;s edge capture register.
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE, 0);
led=led+1;
//initdma();
// irq_count++;
}

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It seems that this condition never happens

    
    if (usedw_r==1)
            valid <= 1;
    
    How can i get the half full signal from an assyncrhonos FIFO???

    And am i writing right to the fifo with my code that i shown in the first post?