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.

TM4C1230H6PM: Timer, Prescale

Part Number: TM4C1230H6PM

I want to use TimerA of TIMER0_BASE with Prescale, and the code is following :


TimerLoadSet(TIMER0_BASE, TIMER_A, 80000000);

TimerIntRegister(TIMER0_BASE, TIMER_A, pfnHandler);
TimerEnable(TIMER0_BASE, TIMER_A);

why this timer is triggered with 1S. because I have set the prescale with 128, should it is triggered with 2S(it's frequency was become 40MHZ)???

thanks for your ask

  • Hello,

    Well for starters, you are not using the timer in Half-Width mode. See the comments for TimerPrescaleSet in the driverlib timer.c file:

    //! This function configures the value of the input clock prescaler.  The
    //! prescaler is only operational when in half-width mode and is used to extend
    //! the range of the half-width timer modes.  The prescaler provides the least
    //! significant bits when counting down in periodic and one-shot modes; in all
    //! other modes, the prescaler provides the most significant bits.

    You need to use the following configuration to set the timer to work in half-width mode which will let you use TimerPrescaleSet then:


    There is a catch you need to be wary of though, which is that you would overrun the Half-timer register with your input of 80000000.

    So you would need to find a way to scale that down to a value less than 65535 to fit within the 16 bit wide half-timer register.

    Hopefully this information is sufficient to allow you to figure out a way to achieve your application, let me know if you have further questions

  • Hello Ralph,

    Believe that you are (exactly) correct - however in this case - is it wise to accept the poster's desire?

    user5858362 said:
    I want to use TimerA of TIMER0_BASE with Prescale

    As you well noted - his 'method' will:

    • 'quickly & repeatedly' overflow his 'Half Timer' - requiring a 'cascade of (overflow) counts' to reach his goal
    • adds the complication of a 'Prescaler'
    • thus will prove 'outside of an efficient & eased solution'

    Instead - the choice of a 'Full-Width' (32 bit Timer) easily accommodates those 80,000,000 counts - while 'dismissing' any need for a 'Prescaler!'

    Experience teaches that when posters present (unexplained, possibly unjustified) 'needs/wants' - rarely are they the (best considered) 'Paths to Success!'

    Without doubt - poster's use of a Full-Width Timer - best enables a 'Speeded, Eased & Enhanced' Solution!

  • Thanks for  Ralph Jacobi engineer's reply. Let me know how to configure the Timer's prescale correctly.

    And I also want to thank cb1_mobile. as what he says, even if i choose Timer's lowest prescaler, that also is not enough for my project.  Finally i must use Full-Width Timer for my project.

    Thanks for anyone who help me