Forum Discussion

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

Interruption program

Hello,

I am trying to do an interruption of a video signal. I am using the hsmc quad video card of Bitec associated to a cyclone III C25 Altera card. An interruption is supposed to be generated at each frame.

First of all, I don't really understand what is the context, and what I should put in the edge_capture variable.

I tried to adapt the interuption program which worked on buttons but no success. It should print "coincoin" whenever an interruption occurs. I put below the parts of my program corresponding to the interruption. Tell me if you need more details.

Thanks for helping,

Myriam

Program :

volatile int pouet=0;

volatile int edge_capture;

static void handle_DMA_interrupts(void* context, alt_u32 id)

{

volatile int* edge_capture_ptr = (volatile int*) context;

if (pouet==0) pouet = 1;

}

Then in, the main :

...

IOWR(video_in_base[0], 0x0, 0x08 ); // enable bit for interrupt

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(VIDEO_1_BASE, 0x01);

alt_irq_register( VIDEO_1_IRQ,&edge_capture, handle_DMA_interrupts );

while ( 1 == 1 )

{

if (pouet == 1)

{printf("coincoin");

pouet == 0;

}

...

}

23 Replies

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

    Can you put a picture of your design to well understand the context please.

    Else, the variable context here is just to save values during ISR. For example in the count_binary example, you have the following :

    
     1 /* A variable to hold the value of the button pio edge capture register. */
     2 volatile int edge_capture;
     3 static void init_button_pio()
     4 {
     5     /* Recast the edge_capture pointer to match the alt_irq_register() function
     6      * prototype. */
     7     void* edge_capture_ptr = (void*) &edge_capture;
     8     /* Enable all 4 button interrupts. */
     9     IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTON_PIO_BASE, 0xf);
    10     /* Reset the edge capture register. */
    11     IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0x0);
    12     /* Register the interrupt handler. */
    13     alt_irq_register( BUTTON_PIO_IRQ, edge_capture_ptr,
    14                       handle_button_interrupts );
    15 }
    16 static void handle_button_interrupts(void* context, alt_u32 id)
    17 {
    18     /* Cast context to edge_capture's type. It is important that this be 
    19      * declared volatile to avoid unwanted compiler optimization.
    20      */
    21     volatile int* edge_capture_ptr = (volatile int*) context;
    22     /* Store the value in the Button's edge capture register in *context. */
    23     *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
    24     /* Reset the Button's edge capture register. */
    25     IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0);
    26     IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE); //An extra read call to clear of delay through the bridge
    27 
    28 }
    
    In the ISR, you get the value of the edge capture register to know which button has been pushed, and store it at the address pointed by edge_capture_ptr. This variable point to the same address as context (line 21). And context has the same address as edge_capture variable (line 13 and 7).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Jerome,

    The only registers I have are those below and I don't see which one could correspond to the edgecapture register.

    The line "IOWR(video_in_base[0], 0x0, 0x08 )" enables the interruption. I tried to put it in the ISR but no more success.

    # define VIDEO_1_NAME "/dev/video_1"# define VIDEO_1_TYPE "bitec_qvideo_in"# define VIDEO_1_BASE 0x00008000# define VIDEO_1_SPAN 128# define VIDEO_1_IRQ 1# define ALT_MODULE_CLASS_video_1 bitec_qvideo_in

    Given the registers, do you have an idea ?

    Thank you for your help,

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

    Hello,

    I do not know exactly the context when working with video, but for the interruption, as in your previous program you have to acknowledge the interruption in the ISR (like write on the edgecapture register for PIO port).

    Jérôme