AnsweredAssumed Answered

example C code for interrupt from DPI pin

Question asked by Milos on Aug 5, 2009
Latest reply on Aug 5, 2009 by Milos

Hello,

 

Does somebody have any example to generate output on the one DPI pin (by flags or misc - I don't know which is better or where is difference.)

and on the other DPI pin (as a input) generate interrupt?

 

I tried  but it doesn't work.

Can you check it?

 

Please help me.

Regards,

Milos

 

 


#include <def21369.h>
#include <cdef21369.h>
#include <signal.h>
#include <sysreg.h>
#include <sru.h>

 

void IRQ_Isr(int sig);

 

int i, j, k=0;

 

int main( void )
{
// Code for connecting as a input (for interrupt): FLAG4 to DPI_PIN07

 

SRU (HIGH, DPI_PBEN07_I);
SRU (FLAG4_O, DPI_PB07_I);

 


// Code for connecting as a input (for interrupt): DPI_PIN8 to MISCB1

 

SRU (DPI_PB08_O, MISCB1_I);
SRU (LOW, DPI_PB08_I);
SRU (LOW, DPI_PBEN08_I);

 


//settings for interrupt

 


    (*pDPI_IRPTL) = (EXT_MISC_1_INT  );    //unmask individual interrupts
    (*pDPI_IRPTL_RE) = (EXT_MISC_1_INT);    //make sure interrupts latch on the rising edge

 

 
    //Set up interrupt priorities
    sysreg_bit_set(sysreg_IMASK, DPII); //make DPI interrupts high priority

    sysreg_bit_set(sysreg_MODE1, IRPTEN );     // Global Interrupt Enable. Enables (if set, = 1) or disables (if cleared,  = 0) all maskable interrupts.

   interrupt(SIG_P14,IRQ_Isr);

//end settings for interrupt

 


// settings for  FLAG4
    sysreg_bit_set(sysreg_FLAGS, (FLG4O) );     //Setting flag pins as outputs
    sysreg_bit_clr(sysreg_FLAGS, (FLG4) );        //Clearing flag pins

 

// end settings for  FLAG4

 

for(i=0;i<10;i++)

 

     {
    sysreg_bit_clr(sysreg_FLAGS, FLG4); //output is LOW

    for(j=0;j<10000000;i++)

              { asm("nop;"); }         //waiting

 

    sysreg_bit_tgl(sysreg_FLAGS, FLG4); //output is HIGH  to generate interrupt

     }

 

}

 

 

 

void IRQ_Isr(int sig)

{

k++;

}

Outcomes