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.

Concerto M3 Timer PWM problem

Other Parts Discussed in Thread: CONTROLSUITE

Hi Guys,

I am working with the Concerto F28M35H52C1.

I am not able to get the Timer PWM mode working, Trying to get it to work from PC5 GPIO69 CCP1.

Here is my code:

SysCtlClockConfigSet( SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xA));

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinConfigure(GPIO_PC5_CCP1);
GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_5);

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_B_PWM);
TimerControlLevel(TIMER0_BASE, TIMER_B, true);
TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/4000);
TimerMatchSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/8000);
TimerEnable(TIMER0_BASE, TIMER_B);

I see nothing on that pin's output...

Any Idea ?

Thanks.

  • Hi Nir,

    Check with this sample project:

    0207.epwm_timer_interrupts.zip

    Regards,

    Gautam

  • Hello Gautam,

    The sample projects uses the C28 DSP to generate PWMs. I can do that also with no problem.

    What I am trying to do is generate PWM signals from the M3,using timer PWM mode ( CCP ).

    Any idea ?

  • Hello Nir!

    You can try the following:

    TimerDisable(TIMER0_BASE,TIMER_BOUTH);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM);

    instead: TimerConfigure(TIMER0_BASE, TIMER_CFG_B_PWM);

    Refer please to ti\controlSUITE\device_support\f28m35x\v160\MWare\driverlib\timer.c

    Regards,

    Igor

  • Thanks Igor,

    Finally I see an output !!!

    I have one more smaller problem now, I am trying to get a lower frequency of PWM by prescaling the timer clock.

    TimerPrescaleSet(TIMER0_BASE,TIMER_B, 4); // 4 for example

    But there is no change in the output...

    Can you help me with that ?

  • Hello!

    Perhaps just the sequence of operations to be performed correctly:

    TimerDisable(TIMER0_BASE,TIMER_BOUTH);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_B_PWM);

    TimerControlLevel(TIMER0_BASE, TIMER_B, true);
    TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/4000);
    TimerMatchSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/8000);

    TimerPrescaleSet(TIMER0_BASE,TIMER_B, 4);

    TimerEnable(TIMER0_BASE, TIMER_B);

    Regards,

    Igor

  • No... :(

    Also tried 

    TimerLoadSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/4000);

    TimerPrescaleSet(TIMER0_BASE,TIMER_B, 4);

    TimerMatchSet(TIMER0_BASE, TIMER_B, SysCtlClockGet()/8000);

    TimerPrescaleMatchSet(TIMER0_BASE,TIMER_B, 4);

    But there is no change in output, I still see 4KHz frequency, 50% Duty cycle.

  • Well, 

    I guess the Prescaler only works in 16-bit mode of the timer, it is written in timer.c driver file.

    Thank you.

  • Hello!

    The devil knows...Your case is a 16-bit just if to refer to timer.c:

    //*****************************************************************************
    //! Configures the timer(s).
    //!
    //! \param ulBase is the base address of the timer module.
    //! \param ulConfig is the configuration for the timer.
    //!
    //! This function configures the operating mode of the timer(s). The timer
    //! module is disabled before being configured, and is left in the disabled
    //! state. The configuration is specified in \e ulConfig as one of the
    //! following values:
    //!
    //! - \b TIMER_CFG_32_BIT_OS - 32-bit one-shot timer
    //! - \b TIMER_CFG_32_BIT_OS_UP - 32-bit one-shot timer that counts up instead
    //! of down (not available on all parts)
    //! - \b TIMER_CFG_32_BIT_PER - 32-bit periodic timer
    //! - \b TIMER_CFG_32_BIT_PER_UP - 32-bit periodic timer that counts up instead
    //! of down (not available on all parts)
    //! - \b TIMER_CFG_32_RTC - 32-bit real time clock timer
    //! - \b TIMER_CFG_16_BIT_PAIR - Two 16-bit timers
    //!
    //! When configured for a pair of 16-bit timers, each timer is separately
    //! configured. The first timer is configured by setting \e ulConfig to
    //! the result of a logical OR operation between one of the following values
    //! and \e ulConfig:
    //!
    //! - \b TIMER_CFG_A_ONE_SHOT - 16-bit one-shot timer
    //! - \b TIMER_CFG_A_ONE_SHOT_UP - 16-bit one-shot timer that counts up instead
    //! of down (not available on all parts)
    //! - \b TIMER_CFG_A_PERIODIC - 16-bit periodic timer
    //! - \b TIMER_CFG_A_PERIODIC_UP - 16-bit periodic timer that counts up instead
    //! of down (not available on all parts)
    //! - \b TIMER_CFG_A_CAP_COUNT - 16-bit edge count capture
    //! - \b TIMER_CFG_A_CAP_TIME - 16-bit edge time capture
    //! - \b TIMER_CFG_A_PWM - 16-bit PWM output
    //!
    //! Similarly, the second timer is configured by setting \e ulConfig to
    //! the result of a logical OR operation between one of the corresponding
    //! \b TIMER_CFG_B_* values and \e ulConfig.

    It seems "TimerPrescaleSet" must work...It is necessary to sort out...

    Regards,

    Igor

  • Well , 

    I guess you are right, it is 16 bit mode with PWM so it must work.

    But 

    TimerPrescaleSet(TIMER0_BASE,TIMER_B, 4);
    TimerPrescaleMatchSet(TIMER0_BASE,TIMER_B, 4);
    have no effect at all  :/
    (Maybe I will try to start a new discussion with that topic ...)
    Thank you very much for the Help.
  • The user manual has a note that says : "The prescaler is not available in 16-Bit PWM mode".

  • Hi Nir,

    I am also using same CPU( F28M35h52C1 ). I faced a problem in SSI( SSI configured as SPI in Cortex M3 ) 

    Please take a look into this problem.

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/275586.aspx

    Thanks in Advance

    Thirumoorthy.R