This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GIO Interrupts-how to set polarity, how to access system clock value when rising edge encountered

Other Parts Discussed in Thread: HALCOGEN

I want to set the polarity for rising edges, for PORTA0,1,2 and want the clock value when each of them encounters a rising edge.

     _enable_IRQ();
    gioInit();    //initialise the gio driver
    gioEnableNotification(gioPORTA,0);    //setting as interrupts
    gioEnableNotification(gioPORTA,1);    //setting as interrupts
    gioEnableNotification(gioPORTA,2);    //setting as interrupts

  • You might find is more straightforward to use the input capture function of the NHET for this job, but you can do it with GIO interrupts as long as you can tolerate some ambiguity if the edges on two different pins arrive too close together.  (close = within interrupt service time).

    The VIM can export any interrupt request to the RTI for the purpose of capture events.

    HalCoGen has a selection box for these outputs on the bottom of it's "Vim General" tab.

    The RTI Chapter of the TRM will show you how the capture events are handled by the RTI:

    There is one capture register for each RTI counter, so if you want two captures you should configure the counters to run at the same rate.  


    For each capture register, you can select which of the 2 capture events to use.  You could set up both capture registers to trigger from the same event,  which could be the GIO interrupt as it reaches VIM.   This will be delayed slightly (few clock cycles) from the actual event at the pin and the capture register would be susceptable to overrun if there are too closely spaced events.  But otherwise this can work.

    If you need to get around any of these limitations, then you should really use the N2HET timer for the capture.  The N2HET can capture the events unambigously with a minimal delay from pin to capture register.  You could also construct an N2HET program to have some additional levels of buffering (double buffered, triple buffered, etc) as needed.   With N2HET the limitation on how closely spaced the edges can be is '0' if the edges are on different pins.  If it's two edges on the same pin, then there is a limit that's slightly larger than the N2HET loop resolution period.  (so typically 500ns or 1us might be your range;  depends on how many cycles you need to execute your N2HET program).