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.

TM4C123GH6PZ: LM4F232H5QC

Part Number: TM4C123GH6PZ

Hi,

anyone please tell me how to generate a delay of 1 sec using timers in TM4C123GH6PZ, i'm getting confused as to what value I have to pass in the TimerLoadSet?, is it system clock frequency?

  • Alam said:
    ... (poster seeks to) generate a delay of 1 sec using timers ... what value is passed to TimerLoadSet?      Is it system clock frequency?

    You understand the essence - that's good - you need (now) to focus in upon the "detail."

    My preference is to "guide you" - not to "Do the job for you."    (you appear smart & motivated enough for that)

    MCU Manual devotes an entire chapter to the MCU's Timer(s).    Have you (really) looked there?    (not a 5 minute job - for most of us...)     The input to the Timers is revealed - and IS the system clock.

    Further review of the "4C123 manual" reveals the, "Usual Timer Durations" (from figure 11.6) extend to 53.7 Seconds - when a "32 bit timer & 80MHz" System Clock are employed.     To achieve your (desired) 1 Second delay you (easily) determine the, "Number of System Clock Periods" which when added together - equal 1 Second.    You may also achieve 1 Sec via a 16 bit timer - yet that involves use of a timer prescalar - which adds complexity - not appropriate for here - or now.

    While "against my will" the determination of a "1 Sec Delay" proves so simple - it is "hard to resist."     As stated - you must load the chosen "32 bit Timer" with the "Number of System Clock PERIODS" which occur w/in 1 Second.     Thus - if "SysClk" is 80MHz - each SysClk PERIOD is 1/80,000,000.     Your Timer is loaded w/ that "80,000,000" - which will consume 1 Sec. prior to exhausting.   (Proof: 80*10^6 * 1/80*10^-6 = 1.)    where 80*10^6 = SysClk.      Note that a "16 bit Timer" accommodates load values of (only) 65K - this is the justification for the 32 bit Timer.    (of course 16 bit Timer + Pre-Scale (could) be employed - that's left for those "interested.")

    For simple delays - especially those used w/Displays - the "One-Shot" Timer Mode is - by FAR - preferred.    Do NOT use Periodic!     You may make "multiple calls" to your 1Sec One-Shot - when longer delays are desired.

    It is hoped that (now) your confusion has ended (as "anyone" has responded - as requested.)

    Speaking to "confusion" - the use of "MCU Part No. (only)" as appears your habit (twice now) is not famed for "well conveying" your subject and interest.    (this is (yet another) weakness of the (claimed) "forum upgrade" which several here hold in high dispute...)     (self-awards (i.e. "upgrade?") - most always prove illusory!)