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.

C2000 fractional frequency modulation



Hello there,

I am mostly using STM32 devices. What I miss there is that I can only adjust the frequency of a timer very poorly, its inger based. I was wondering either C2000 introduces any DDS functionalities, where it is possible to change the timers frequency more preciselly. Something like with NCO. Would it be possible for example, to change the frequency of a timer from 1 Hz to 1 MHz with 1 Hz step?

I am just asking because I find STM32 more and more limiting and I was wondering either it is worth jumping to C2000.

I would appreciate all help!

  • Hello Lukasz,

    Yes, almost all current C2000 devices have this capability.  The PWM generators are equipped with high-resolution mode which allows edges to be positioned with very high precision.  The amount depends on the device, but 150ps or so is typical (in the example you give, about 1ns of precision is required).  High resolution mode can be applied to PWM duty cycle, phase or frequency.

    You can read more about this feature in chapter 14 of the User's manual of the recent F38075 device:

    http://www.ti.com/lit/ug/spruhm9b/spruhm9b.pdf

    I hope this helps.

    Regards,

    Richard

  • Hi Lukasz,

    The C2000 timer period is a 32-bit number of CPU cycles. You can probably get within 2% of your target, but it doesn't sound like that's good enough.

    I'll ask our System Apps team to look at your post. There might be a better way of doing DDS on C2000 MCUs.
  • Thank you for help guys. Ill be looking forward to it.

    Ps: please keep in mind that frequency is the desired modulated value, not pulse width.

  • Looks like Richard beat me to it! The HRPWM should do what you need.
  • Yes but it looks like I could set pulse width very precisely, asymmetrically and etc. But I cant find anything about frequency setting. It doesn't even have to be connected with PWM, I just need the timer.
  • Lukasz,

    Well, maybe I've misunderstood.  On C2000, PWM frequency can be adjusted with high precision as described, together with pulse width and phase, however the technique does not change the under-lying timer.  Section 14.2.4.4 gives an example.  However if you're only interested in the timer and not in the PWM waveform then it doesn't apply.  

    Also, I made a mistake in my earlier calculation.  Even with HR mode, 1Hz resolution at 1MHz is unachievable.  You would need a 1ps resolution for that, not 1ns as I said.  Sorry if I've misled you.

    Regards,

    Richard

  • For 1MHz freq, period is 1us, or do you mean there is some additional overhead? What i need really, is to fire an interrupt with set frequency, that varies from 1 hz to 1 MHz.
  • Lukasz,

    If I've understood, you're looking for 1Hz frequency resolution at 1MHz?  Therefore an adjacent frequency is 999.999kHz.  What I mean is that the two periods are separated by 1ps: i.e. 1us and 1.000001us respectively. Even if you just wanted that kind of PWM frequency variation it's beyond the reach of HR mode.

    Interrupt generation is always synchronous with the timebase counter, so its' resolution is tied to CPU clock frequency.  For example, a 200MHz device has clock period of 5ns, so that's the resolution on interrupt period too.  At this clock rate you could achieve a 1MHz interrupt, but the next lowest achievable frequency would be 995.024kHz.

    Regards,

    Richard

  • Yes, thats what i was afraid of. I thought maybe c2000 has some more distinguished timer prescaler capabilities.


    Edit: So to sum this up- There is no other way of setting timers tick frequency in C2000 than using the equasion:

    Freq = SysClk / ( (Prescaller + 1) * Period )

    Am i correct? No NCO based mechanisms like with DDS?
  • Hi Lukasz,

    What exactly are you trying to accomplish? As Richard pointed out, generating an interrupt with higher resolution than the CPU clock is not worthwhile, even if it was possible, because the interrupt will cause the CPU to execute code, which is always synchronous with the CPU clock. To get the resolution you want, the control signals are probably going to have to leave the device, regardless of architectural features and available peripherals.