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.

TMS320F28069: CPU timer 0 frequency not correct

Part Number: TMS320F28069


Hi 

I have been using cpu timer 0 ISR in my project for sine wave generation. 
I generated a 50Hz sine wave using rampgen library with 20kHz ISR. But when i observed it with a precision power analyser, it showed 50.2Hz. 
Therefore i used 49.8Hz as the rampgen frequency and got 50Hz output.
But i also noticed that the power measure sine analyser library also detects the frequency as 49.8 Hz,  while actual frequency is 50Hz.

Checked the ISR running frequency with gpio toggle and an oscilloscope. Output showed as 20.16kHz. 


Therefore I play around with the cpu timer 0 period config value and found out that 50.2 micro second gives the exact outputs i want. All things were as expected. 

for 20kHz, correct value for period should be 50. But the working value is 50.2.  Why is that. 

ConfigCpuTimer(&CpuTimer0, 90,50.2);

Regards
Damith

  • Hi Damith,

    There will always be internal HW delay from CPU timer expiring to the time ISR getting generated and toggling the GPIO. You are seeing ~200ns (~20 cycles if you have configured SYSCLK=90MHz) delay which is expected. Again this internal delay can vary by few cycles across voltage and temperature.

    Best Regards,

    Nirav

  • Hi Nirav

    Thank you very much for the reply.
    Please note that the problem is not only for the GPIO.  As i stated in the question, Rampgen library and sine analyzer libraries also give wrong values, 49.8Hz instead of 50Hz.

    This was checked with precision power analyzer using SPWM generated sine wave and with giving 50Hz input to the ADC.  It only give right values after i entered the CPUtimer period value as 50.2.

    Let me state what i did, which may clarify things.


    Generated 50hz signal with rampgen running at 20Khz and used it to generate 50Hz sine wave with SPWM inverter.
    Checked it with a precision power analyzer. Result was 50.2Hz. 
    So i gave 49.8Hz as the rampgen frequency and got exactly 50Hz.

    Gave a 50Hz sine wave signal to ADC. Measured it with TI sine analyser library running at 20k.
    Frequency shows as 49.8Hz.

    So i experimented and found out that 50.2 as cpu timer period value give the expected results.
    Tried with several 320F28069 MCUs. Result is same

    Is there a possibility that the system configuration/initialization issue cause this problem?.

    Regards
    Damih

  • Hi Nirav,

    I noticed that when i changed the clock source from internal osc to external crystal, Problem seems to be solved. 
    Any idea why this happen when internal OSC is used. 

    Regards
    Damith

  • Hi Damith,

    INTOSC accuracy is +/-3% (refer datasheet), that is the reason why you see delta from expected 50Hz.. 

    Best Regards,

    Nirav

  • Hi Nirav

    If thats the case, then frequency value should be change for different MCUs right.? For example, one MCU shows 50.1Hz another one may shows 49.9Hz, like that . But i used same code in several 28069M MCUs and still I get the same 50.2Hz value every time.

    So this is not related to that frequency drift. Drift value for all MCUs should not be same.

    Regards

    Damith

  • Hi Damith,

    It is possible that all the MCUs that you have are showing same INTOSC frequency, which is off from 10Mhz. Reason I say that is possible is because +/-3% drift is across temperature. I am assuming that you have this at same temperature across multiple MCUs. In order to compensate for temperature drift and bound the tolerance to +/-3% INTOSC target frequency will be slightly off from 10Mhz, hence your assumption of INTOSC being 10Mhz may not be true, and hence you are seeing 50.2Hz.

    One way to check that would be to bring out the INTOSC clock on XCLKOUT and measure frequency to check if it is centered at 10MHz, or is off.

    Best Regards,

    Nirav

  • Hi Nirav

    Thank you for the explanation. 

    Regards 
    Damith