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.

Example interrupt change edge in lm4f232

I need to write a routine that counts how many pulses "interruptions" that received a particular pin. These interruptions would have to be a change of state of pin 0 to 5V, this must be a high priority interrupt. As I am new in programming Arm, I wonder how to set the example by Pino Pd0 pin to be responsible for this change of state. I am using CCS v5.2

 

  • You should beware that PD0 serves a special purpose - requires special care/handling - thus complicates your task.  Suspect you'd do well to choose a less complex pin - so that you can better focus upon your "real" requirement...

  • I can use any pin, please send-me a sample with any other pin. i need simple receive interrupt and increase a counter.

  • Why must this be a high priority interrupt?  What other interrupts are in play?  How do you intend to "view" this, "low to high" signal transition detect counter?

  • Can be high priority, i need detect transition low to high.

    I need read a circular encoder for a DC motor and count for get position. encoder (IN) have a 5v digital output

     

  • Have you had a chance to fully read and absorb the detailed datasheet for this M4 MCU?  What you seek may already exist w/in this MCU - and may be more effective than the method you currently propose...

  • i read about Quadrature Encoder Interface (QEI) but i prefer make a manual control, due to port this application to other MCU in future. can you help-me with simple interrupt ?

  • rodrigo zimmerman said:
    can you help-me with simple interrupt ?

    Quite likely - have you looked @ the multiple examples that are included with your 4F Eval board?   Interrupts abound.  SW-DRL-UG has an entire chapter on interrupts and the MCU datasheet provides nuts/bolts. 

    I'm interpreting your "help" more as a, "do it for me" - doubt that best serves you in the long run.  If you put forth reasonable effort - display it here - interested/capable responders appear often. 

    Porting to another MCU - so significant in your post - really seems unfair/unkind to forum's MCU vendor...

  • void IntGPIOm(void) { //interrupt counter and show counter    

        char pcBuffer[16];

        contador++;  usnprintf(pcBuffer, 16, " %d ", contador);

        GrStringDraw(&g_sContext, pcBuffer, -1, 48, 32, 1);

        ROM_GPIOPinIntClear(GPIO_PORTM_BASE, GPIO_PIN_0);

    }

      main()  

    { .....     

    contador = 0;//reset counter    

    ROM_IntPrioritySet(INT_GPIOM, 0x00);//set the interrupt with high priority    

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);//enable the portm    

    ROM_GPIOPinTypeGPIOInput(GPIO_PORTM_BASE, GPIO_PIN_0 );//enabled pm0 as input    

    ROM_GPIOPadConfigSet(GPIO_PORTM_BASE , GPIO_PIN_0 ,  GPIO_STRENGTH_2MA ,  GPIO_PIN_TYPE_STD_WPU); // set the pm0 with 2ma pull up resistor     ROM_GPIOIntTypeSet(GPIO_PORTM_BASE , GPIO_PIN_0 , GPIO_RISING_EDGE); // seting the interrupt as rising edge    

    ROM_GPIOPinIntEnable(GPIO_PORTM_BASE, GPIO_PIN_0 );//enaled interrupt in pmo    

    ROM_IntEnable(INT_GPIOM);//setting interrupt IntGPIOm don't forget put IntGPIOm in STARTUP_ccs.c    

    ROM_GPIOPinIntClear(GPIO_PORTM_BASE, GPIO_PIN_0);//clear interrupt flag    

    IntMasterEnable();//enable master interrupt fuse    

    while (1){          

    }  

     }