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.

TMS320F28069M: CPU Timer in nanoseconds

Part Number: TMS320F28069M
Other Parts Discussed in Thread: C2000WARE

Hi there,

I'm trying to configure the CPU timer in nanoseconds to generate clock signals with 3MHz frequency. I've modified the ConfigCpuTimer code found in C2000ware (which was configured in microseconds) as below:

void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float BlinkIntervalInNs)
{
    // Calculate clock period in nanoseconds
    float ClockPeriodInNs = 1.0 / Freq * 1000 * 1000;

    // Calculate PRD for desired blink interval
    Uint32 PeriodInClocks = (Uint32)(BlinkIntervalInNs / ClockPeriodInNs);

(I set the input clock for the timer as 90MHz)

I used an oscilloscope to observe the signal, and it was successfully generated until the output clock signal reached a frequency of 1.33MHz. However, signals weren't generated at all when I set the BlinkInterval such that the output clock frequency was above 1.33MHz.

I'm struggling with how to solve this issue. Could anyone give me advice about it? Thanks.

  • Hi Gen,

    What clock source are you using in your example? Have you made any other changes to the PLL (systctrl.c) or options which differ from those provide in the example CPU Timer example?

    Regards,

    Ozino

  • Hi Ozino,

    I'm using CPU Timer 0 as the clock source, and I haven't changed anything in SysCtrl.c. 

    The changes I made are:

    • CpuTimers.c
      • ConfigCpuTImer (as I described in the original post)
    • LEDBlink.c (I modified this code to generate the output clock signal) 
      • Changed the output pin from GPIO 0 to GPIO 34

    Other than the above, I kept my code the same as what's provided in the example.

    Kind regards,

    Gen

  • Hi Gen, I'm reassigning this thread to another subject matter expert.  Unfortunately, he is out of office today but should be able to reply Monday.  That said, you might try stepping through the code and 'watch' your key variables.  I am wondering if one of the variables is overflowing when you push the output frequency to 1.33MHz.

  • Hello Gen,

    In addition to what Joe has mentioned, can you also send me a screenshot? I want to verify that the values are within the parameters for the timer registers. Also, your code snippet above does not show how these new nanosecond versions of the parameters get loaded into the timer registers, can you please show the entire ConfigCpuTimer function?

  • Hello Joe and Omer,

    Please see below for the entire ConfigCpuTimer function. I'll also try to step through the code to see key variables.

    void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float BlinkIntervalInNs)
    {
        // Calculate clock period in nanoseconds
        float ClockPeriodInNs = 1.0 / Freq * 1000 * 1000;
    
        // Calculate PRD for desired blink interval
        Uint32 PeriodInClocks = (Uint32)(BlinkIntervalInNs / ClockPeriodInNs);
    
        // Update PRD and other configurations
        Timer->RegsAddr->PRD.all = PeriodInClocks - 1;
        Timer->RegsAddr->TPR.all = 0;
        Timer->RegsAddr->TPRH.all = 0;
        Timer->RegsAddr->TCR.bit.TSS = 1;
        Timer->RegsAddr->TCR.bit.TRB = 1;
        Timer->RegsAddr->TCR.bit.SOFT = 0;
        Timer->RegsAddr->TCR.bit.FREE = 0;
        Timer->RegsAddr->TCR.bit.TIE = 1;
    
        // Reset interrupt counter
        Timer->InterruptCount = 0;
    }

    Kind regards,

    Gen

  • Hello Gen,

    Assuming you call the function like ConfigCpuTimer(&CpuTimer0, 90, 380) or something similar for 1.33 MHz frequency on the output, the value you're trying to store in the timer period register would be 0x7 F67A 9600, which requires at least 35 bits. The TIMERxPRD register is only 32 bits wide total (split with the PRD and PRDH 16-bit registers). Therefore this period is not possible given the register constraints.

    The maximum value you can store in the PRD+PRDH register is 0xFFFF FFFF or 4,294,967,295.