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.

TM4C1290NCPDT: Generate Low Frequency (>0.005 and 20Hz) with microHz accuracy

Part Number: TM4C1290NCPDT

Dear Sir,

I want to make the Frequency Generator with High Accuracy in range between 0.0005 Hz to 20 Hz  with the accuracy of microHz ie. 1.00001 

I have tried with the 32bit concatenate Timer bit I put the Counts as per frequency with the formuale of ((ui32SysClock / (frequency_Hz)) / 2);  where frequency_Hz is the Frequecny which we want to give as output now It will do that accordingly but it doesnt give me proper accuracy of micro Hz and it flucatues the Output freq.

Can you please suggest me how to got such accuracy with now fluctations.

  • Smit,

    Are you saying you want generate a pulse that will be as slow as ONE EVERY 2000 SECONDS, and you want it with millisecond precision? You won't be able to achieve that without additional external references.

    If you can live with the TM4C's clock precision, it won't be too difficult:

    Since the TM4C129x timer has a maximum load of 32 bits (~4.2 billion) and your slower period @120MHz clock is ~240 billion ticks, you will need to use an auxiliary counter inside your timer interrupt. One option for example would be to configure your timer to expire every systemClock ticks (usually 120MHz), which would bring you to the ISR once per second. On the second last service, you'd configure your pin to raise on the next timer count, using some of the TIMER_CFG_A_ACT_SETTO options.

    For "lazy implementation", TM4C123's have 64bit HUGE wide timer - so all you need to do is load your timer with the amount of clicks you need.

    You will need to calculate the clock precision from the datasheet - and if you really require that precision, you will need some external time calibration help. Depending on your application, GPS receivers usually have reliable time references at ~10ns. Or a calibrated crystal, associated to a temperature compensated routine... There's a whole "science" to precision timekeeping.

    Cheers

    Bruno
  • Thanks Bruno For your suggested reply to my query!
    I have use the Timer as Configure TIMER_CFG_PERIODIC Now as you suggested in your reply that i have to use some sort of auxiliary counter ain timer Interrupt !

    Please elaborate me the same

    Thank you in advance
  • Just for example, let's say:

    - you need a transition in 7 seconds.
    - your main clock running at 120MHz.
    - you load your timer at 60.000.000 (which will call the ISR every 0.5 seconds)

    Inside the ISR, you define a static variable "timerCallsCounter". Every time the ISR is called you increase the counter. On the first 15 interrupts, you don't touch your TCCP at all. When timerCallsCounter equals 15 (in 6.5 seconds), you are only half a second away from your desired time, so that's when you configure your TCCP to toggle or set the next time the timer counter expires.

    Of course, then the game starts all over, you need to reset your timerCallsCounter and whatever else controls you are using. Also, this example has a period that is a perfect multiple of the timer count, but you can play with the timer count values for different desired periods.

    Cheers
  • Thanks for getting me understand this concept !

    But what is i want to generate 6..85sec with your concept of 0.5sec can i use your concept in the same?
  • Yes, you can.
    Try learning simpler timer interrupts first, until you master them. Using a counter later is a mere programming detail.
    Actually, if you are running @120MHz, you can use the 32bit timer all the way to ~35.7 seconds. Just do the math.
    You will only need to manage consecutive timeouts if you want more than that (you mentioned 2000 seconds initially).
    Bruno