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.

How can i disable WTIMER0 or PC5 GPIO pin?

void initPWM(void){


uint32_t ulPeriod, dutyCycle;

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // Enable port C
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0); // Enable Timer 0
ROM_GPIOPinConfigure(GPIO_PC5_WT0CCP1); // Configure pin PC5 as output of Timer 0_B
ROM_GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_5); // Enable pin PC5 as output of timer addressed to it

ulPeriod = ROM_SysCtlClockGet() / MOTOR_PWM_HZ;
dutyCycle = (unsigned long)(ulPeriod-1)*0.25;

ROM_TimerConfigure(WTIMER0_BASE, (TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_PWM)); // Configure Timer 0 as two 32 but timers with both functioning as PWM
ROM_TimerControlLevel(WTIMER0_BASE, TIMER_B, false); // Timer 0 is trigger false invert
ROM_TimerLoadSet(WTIMER0_BASE, TIMER_B, ulPeriod-1); // Timer 0 Load set
ROM_TimerMatchSet(WTIMER0_BASE, TIMER_B, dutyCycle); // Timer 0 Match set
ROM_TimerEnable(WTIMER0_BASE, TIMER_B); nincs bekapcsolva

}

  • Not work:

    void disable(void){
    ROM_TimerDisable(WTIMER0_BASE, TIMER_B);
    ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0);
    }

  • Hello Gergely,

    As you mentioned in the code. Disable the timer first. If the idea is to get the output on the GPIO Back to 0, then first call the API GPIOPinTypeGPIOOutput to make it a GPIO first and then perform a write.

    However when the timer is begun again then the Timer Pin Configuration must be done.

    Regards
    Amit
  • Strange that you seek to, "Disable WTimer0 or PC5 GPIO."    Most all arrive here to learn how to (properly), "Enable Timers or GPIOs"

    Might it be that you (really) seek to "Output" Timer0?    And - that's not possible (directly) unless you configure the timer into its PWM mode.   Then - and only then - that timer signal may appear at its specified MCU pin as an output signal.

    Indirectly - usually via interrupts - you can have a "timer toggle" cause a (different) GPIO pin to output.   Such tracks the timer signal yet is somewhat "delayed" due to interrupt response & service delays.   If you can "massage" identical handling of both timer toggle states - those delays may be identical - and then while your output will be slightly delayed - the signal's duration will be greatly intact.

    Your objective remains unclear - brevity may be the soul of wit - yet is not, "soul of communication."