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.

Questions on Stellaris M4 Timers PWM Mode

Other Parts Discussed in Thread: LM3S1968

Hi i Have a few questions regarding the timer of the Stellaris M4 (LM4f120H5QR).

How can i control PWM frequency in PWM mode?
As I understood the datasheet the prescaler registers does not work as prescaler but as counter extension.
The other question is: if they work as extension - how to set the upper bits of the interval load registers?

does the driver library encapsulates theese strange register reuses and value that are compoundet from multiple registers?

best regards

  • Hi,

    Refer to C:\StellarisWare\examples\peripherals\timer\pwm.c for an example of how to use PWM mode. You can use the TimerPrescaleSet function in StellarisWare to load the prescaler.  

    When using the 16/32-bit timers, the prescaler value is accessible in the GPTMTAV register. From the description of the GPTMTAV register:

    When a 16/32-bit GPTM is configured to one of the 32-bit modes, GPTMTAV appears as a 32-bit
    register (the upper 16-bits correspond to the contents of the GPTM Timer B Value (GPTMTBV)
    register). In a 16-bit mode, bits 15:0 contain the value of the counter and bits 23:16 contain the
    current, free-running value of the prescaler, which is the upper 8 bits of the count in Input Edge
    Count, Input Edge Time, PWM and one-shot or periodic up count modes. In one-shot or periodic
    down count modes, the prescaler stored in 23:16 is a true prescaler, meaning bits 23:16 count down
    before decrementing the value in bits 15:0. The prescaler in bits 31:24 always reads as 0.

    Regards,

    Sue 

  • thanks for your reply but you did not answer my questions :(

    Ren�� Staffen said:
    How can i control PWM frequency in PWM mode?

    the example only shows how to set the duty cycle.
    Sure the frequency is also affected by the TimerLoadSet But changing this value will also affekt the duty cycle and the frequency cannot reduced below 1220Hz if the Sysclock is running with 80Mhz.

    Ren�� Staffen said:
    As I understood the datasheet the prescaler registers does not work as prescaler but as counter extension.

    is this correct or did i misunderstood something?

    Ren�� Staffen said:
    The other question is: if they work as extension - how to set the upper bits of the interval load registers?

    the register you named contains the current timer value or am i wrong?
    I wanted to know the extension 23:16bits of the GPTMTAILR and GPTMTBILR to set the start value of the count down sequence.
    If this cannot be set that is the use of GPTMTAPMR and GPTMTBPMR?

    And finally this question:

    Ren�� Staffen said:
    does the driver library encapsulates theese strange register reuses and value that are compoundet from multiple registers?

    does the driver library set the full 24bit value if i call TimerMatchSet or TimerLoadSet or does i have to call TimerPrescaleSet or something other. Or does the TimerValueGet return the full 24bit value?

  • When using the GPTM, the timer only runs at the system frequency.  You cannot change that.  When you use the PWM module that is available on some devices, you do have control of the frequency.

    As stated in the verbiage I copied from the data sheet, the prescaler contains bits 23:16 of the count in PWM mode.

    You set the value of the prescaler using the TimerPrescaleSet function in StellarisWare as I mentioned.  If you want to write to a register directly, you use the GPTMTAPR register.

    The Peripheral Driver Library has separate functions for the prescaler - prescaler values are not read or written using the basic functions.

    I'm sorry I wasn't clear.

    Regards,

    Sue

  • xin chào
    tôi là người mới sử dụng kit lm3s1968, hiện nay tôi đang làm dự án làm robot cắt cỏ sử dụng lm3s1968. mọi người hưởng dẩn tôi về ngắt sử dụng RTOS của lm3s1968.
    cám ơn mọi người

  • hello
    I'm new to kit lm3s1968, I am currently doing project robot mowers use lm3s1968. people to guide me on using RTOS interrupt of lm3s1968.
    thank you everyone