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.

Lm230H5QR WideTimer PWM



Hello all,

I assume I am doing something foolish, but I haven't been able to figure it out.  I am looking at using a wide timer on the LM230H5QR as a PWM output on a custom board.  I have used the stellaris/tiva function calls before on a standard timer with success.  Unfortunately I haven't been able to use the wide timer as a PWM output.  Here is what I have.  

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);
GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6,0);

SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER5);
GPIOPadConfigSet(WTIMER5_BASE, GPIO_PIN_6, GPIO_STRENGTH_8MA_SC, GPIO_PIN_TYPE_STD);
GPIOPinConfigure(GPIO_PD6_WT5CCP0);
GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_6);

TimerConfigure(WTIMER5_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
TimerLoadSet(WTIMER5_BASE, TIMER_A, 2000);
TimerMatchSet(WTIMER5_BASE, TIMER_A, 1000);
TimerEnable(WTIMER5_BASE, TIMER_A);

WT5CCP0 is muxed with PD6.  I believe I have it set up correctly.  I am not concerned with the load or match values.  I can alter those later.  Right now I just want to get a PWM signal out.  Currently I set up the PWM signal and enter a forever loop just to see if it works.  The output on the pin goes high with some noise.  The same function call series works with on a standard timer PWM.  In the future I would like to use the ROM function calls, but right now I am desperate to get anything working.

Any help would be greatly appreciated.

Jeff 

  • Jeff,

    Two things: (1) The call you have to GPIOPadConfigSet() is redundant since GPIOPinTypeTimer() calls that function anyway, and (2) are you calling TimerConfigure again after this code segment for possibly configuring TIMER_B? If the latter is true then the problem is that TimerConfigure actually configures both TIMER_A and TIMER_B, so if you call it again with, say, TIMER_CFG_B_PWM and not TIMER_CFG_A_PWM, the timer A configuration actually gets erased. You'll notice in the TimerConfigure() source in timer.c that it writes to both TAMR and TBMR.

    If this is not the case though, is there any chance you could post your complete project?

    -Reagan

  • Hi Reagan,

    I removed the padconfigset with no luck.  I have been working on just getting this section to work.  After enable WTIMER5_BASE I have my code enter a forever loop so that I may verifiy operation of the PWM signal.  There really isn't a whole lot more to see.  I am using TIMER0 to verify the code works on a standard timer (which it does).

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    GPIOPinConfigure(GPIO_PB6_T0CCP0);
    GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_6);
    TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
    TimerLoadSet(TIMER0_BASE, TIMER_A, 2000);
    TimerMatchSet(TIMER0_BASE, TIMER_A, 1000);
    TimerEnable(TIMER0_BASE, TIMER_A);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);

    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6,0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER5);
    TimerDisable(WTIMER5_BASE, TIMER_A);
    GPIOPinConfigure(GPIO_PD6_WT5CCP0);
    GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_6);

    TimerConfigure(WTIMER5_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
    TimerLoadSet(WTIMER5_BASE, TIMER_A, 2000);
    TimerMatchSet(WTIMER5_BASE, TIMER_A, 1000);
    TimerEnable(WTIMER5_BASE, TIMER_A);

    while (1){}

  • Posted what I believe to the the very first "Wide Timer" solution on Stellaris forum - many months past.  Here again - for your review: (that post (code extract repeated here) awarded "Verify Answer" by vendor - although ignored by (ungrateful poster recipient) - not that I track such detail... (much)

    void
    timer_set_up(void)
    {
     
      ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER4);
     
      ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    //  HWREG(GPIO_PORTD_BASE + GPIO_O_DR8R) |= 0x10;

      ROM_GPIOPinConfigure(GPIO_PD4_WT4CCP0);

      ROM_GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_4);
     
      ROM_TimerConfigure(WTIMER4_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM);
     
      ROM_TimerLoadSet(WTIMER4_BASE, TIMER_A, 800000);

      ROM_TimerMatchSet(WTIMER4_BASE, TIMER_A, 750000);
      
      ROM_TimerEnable(WTIMER4_BASE, TIMER_A);

    }

    Your latest code is good match to my earlier post - but for:

    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);

    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6,0);

    And - we note no, "ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);"

    Kill these - they are extremely suspect - the ARM timers are smart enough to "know how" to configure themselves as outputs when in Timer -> PWM Mode.  Your use of TimerDisable() is good - but makes sense to (temporarily) remove - to comply w/my example which has again passed vendor scrutiny.

  • Jeff,

    Could you by any chance just post your project? I added this code with the function call below prior to anything, and it worked for me, to output a PWM on PD6.

    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    Regards,

    Reagan