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.

Timer12 clock source

Hi, all

Our processor is DRA75x.

We want to use timer-12 to capture extern PWM(25 Khz). According to datasheet, clock source of timer-12 is OSC_32K_CLK.

1.Is it possible for timer-12 to capture 25Khz PWM?

2.Now, we use below command to configure timer-12 register, try to capture frequency, the result of (TCAR2 - TCAR1) is 3, is it correct?

devmem2 0x4AE20010 w 0x0000000D
devmem2 0x4AE20010 w 0x00000004
devmem2 0x4AE20034 w 0x7
devmem2 0x4AE20054 w 0x4

devmem2 0x4AE20038 w 0x2

devmem2 0x4AE20038 w 0x4002
devmem2 0x4AE20038 w 0x6002
devmem2 0x4AE20038 w 0x6102

devmem2 0x4AE2002C w 0x4

devmem2 0x4AE20038 w 0x6103

Regards,

Shawn

  • Hi Shawn,

    Timer12 is not suitable measure frequency for 2 reasons:
    1. OSC_32k_CLK is coming from an internal R-C oscillator, which is not precise
    2. You need much higher frequency to measure ~25-k signal period with sufficient accuracy (for example ten times or more depending on your needs).

    Regards,
    Stan
  • Hi, Stan,

    Thanks for your reply. I have 2 more questions,
    1. If i still need to use timer-12 to measure frequency, how about measurement for only 1Khz frequency? Will it be sufficient accuracy?
    2.Right now, i can generate PWM signal with 50% duty cycle, if i try to generate 10% or 30% duty cycle, how could i achieve it?

    Regards,
    Shawn
  • Hi Shawn,

    1. You will have a resolution of 32 steps, it is up to your application if it is sufficient or not. But the internal RC oscillator has poor accuracy no matter how good is your resolution. Imagine a wall clock. It has the perfect resolution of 60 minutes per hour, but doesn't mean it will always show the correct time of the day.

    2. You will need a resolution 10 steps. Since timer12 has fixed frequency of ~32 kHz, your PWM signal should be @ 3.2 kHz.

    Regards,

    Stan

  • Hi, Stan,

    Currently, i get difference between TCAR1 and TCAR2 is about 37 for 1KHZ measurement. After calculation, i get the measurement of frequency about 864HZ
    => 1/(37 * (1/32KHZ)) = 864
    Is this a reasonable deviation?

    Regards,
    Shawn
  • Shawn,

    You are correct, but 32 counts could be if R-C oscillator ran at 32-kHz. Looks like in your case it runs slower.
    Actually you have already measured the # of counts in the period of 1-kHz signal.
    Knowing that 1-kHz is precise, you measured 37 counts, then you can calibrate:
    1/(37 * 1/37) = 1 kHz
    This is not the best method, because it doesn't take into account if we are anywhere in the middle between 37 and 38, but you can get the idea.

    Next time, in your field application, if it measures 38 counts then:
    1/(38 * 1/37) = 974 Hz actual
    if 36:
    1/(36 * 1/37) = 1028 Hz actual
    etc.

    If you do enough calibrations (on enough devices) then I think you could get reasonable results.
    Don't forget that ambient temperature will also affect the oscillator speed.

    Regards,
    Stan
  • Hi, Stan,

    Got it. Like you say, basically, i should get 32 count for 1Khz, but now, i only get 35, 36, 37 count, which mean in our field, oscillator is not accuracy ran at 32-Khz.

    Is this oscillator has spec. for it's speed related to temperature?

    Regards,

    Shawn

  • Shawn,

    What I know is that the oscillator frequency will change with PVT (process-voltage-temperature) variations, I don't think any tests were made.