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.

TM4C1290NCPDT: Calling PWMPulseWidthSet() procedure inside the GPIO interrupt

Part Number: TM4C1290NCPDT

TI Friend and Family,

Our customer needs some clarification on the (new) TivaWare API released just last month.

They use PWM to drive the DC stepper motor (PWM on PG0) and an optical switch to stop the motor when initial position is reached.

The optical switch is connected to input Pin 5 of GPIO Port P.  The opto LED is connected to output Pin 4 of GPIO Port P.

When they use GPIOIntTypeSet( PORT_TA_OPTICAL_IN_BASE, PIN_TA_OPTICAL_IN, GPIO_LOW_LEVEL | GPIO_DISCRETE_INT) with GPIOIntRegisterPin( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler ), there is no interrupt.

When they use GPIOIntTypeSet( PORT_TA_OPTICAL_IN_BASE, PIN_TA_OPTICAL_IN, GPIO_LOW_LEVEL) with GPIOIntRegister( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler2 ), they stay in a loop inside the interrupt handler OpticalIntHandler2.  SUrprisingly, even when they use GPIOIntClear( PORT_TA_OPTICAL_IN_BASE , ulStatus ) in the interrupt handler.

Maybe we misunderstood the documentation and the new API ? They currently use TivaWare_C_Series-2.2.0.295.

Is it possible to call PWMPulseWidthSet() procedure inside the GPIO interrupt h?  We believe that to be true, but of course any pointers or info you can share is greatly appreciated.

TY,

CY

  • Hi Chris,

      

    Chris Yorkey said:
    When they use GPIOIntTypeSet( PORT_TA_OPTICAL_IN_BASE, PIN_TA_OPTICAL_IN, GPIO_LOW_LEVEL | GPIO_DISCRETE_INT) with GPIOIntRegisterPin( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler ), there is no interrupt.

     Which port is PORT_TA_OPTICAL_IN_BASE? Your customer redefine the port with his own #define. Please note that only Port Px and Qx have pin level interrupt capability. 

    Not all ports can use GPIO_DISCRETE_INT. So which port is the customer using?

    Chris Yorkey said:
    When they use GPIOIntTypeSet( PORT_TA_OPTICAL_IN_BASE, PIN_TA_OPTICAL_IN, GPIO_LOW_LEVEL) with GPIOIntRegister( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler2 ), they stay in a loop inside the interrupt handler OpticalIntHandler2.  SUrprisingly, even when they use GPIOIntClear( PORT_TA_OPTICAL_IN_BASE , ulStatus ) in the interrupt handler.

    GPIOIntRegister() only takes two arguments. You have it as GPIOIntRegister( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler2 ) with three arguments. I'm surprised it even compiles. 

    Chris Yorkey said:
    Maybe we misunderstood the documentation and the new API ? They currently use TivaWare_C_Series-2.2.0.295.

    Which new API are you talking about? There is no new API added to PWM module and the only new API added for GPIO is the GPIOUnlockPin(). Everything else is the same as far as these two modules are concerned. 

    Chris Yorkey said:
    Is it possible to call PWMPulseWidthSet() procedure inside the GPIO interrupt h?  We believe that to be true, but of course any pointers or info you can share is greatly appreciated.

      I don't see an issue but you need to make sure you enable the sync update so that the duty cycle does not change immediately so the new value is only queued up and takes effect when the counter becomes zero.

     

  • Hello Charles,

    Truly appreciate the quick and detailed reply!

    I have asked the customer to review your post and respond accordingly.

    Stay tuned.

    Thanks again,

    Chris

  • Hello,

    Thank you for your feedback.

    I am using Port P, so the GPIO_DISCRETE_INT applies.

    My bad, I did a copy past on GPIOIntRegister( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler2) in my message.

    In the code I am actually using GPIOIntRegisterPin( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN, OpticalIntHandler2) hence the 3 arguments.

    The issue is solved by disabling the interrupt after the GPIOIntClear( PORT_TA_OPTICAL_IN_BASE , ulStatus ) and using GPIOIntDisable( PORT_TA_OPTICAL_IN_BASE , PIN_INT_OPTICAL_IN ).

    Thanks,

    Nihad

  • Hi, 

      Glad your issue is solved.