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.

TMS320F280025C: nanosecond Timer

Part Number: TMS320F280025C


Hi,

I want to implement timer in nanosecond in my code. I have already implemented timer in microsecond. As per example given in C2000 ware for timer we can only set minimum timer of 1 microsecond in given function(last argument).

configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 1);

I am using internal oscillator clock for this which is 10Mhz.

  • Hi Raj,

    If you would like to configure the timer for nanoseconds then I would alter the configCPUTimer function itself.

    This is the beginning of the function below:

    void
    configCPUTimer(uint32_t cpuTimer, float freq, float period)
    {
        uint32_t temp;
    
        //
        // Initialize timer period:
        //
        temp = (uint32_t)(freq / 1000000 * period);
        CPUTimer_setPeriod(cpuTimer, temp);
    

    The key within this function is CPUTimer_setPeriod(). This function is what configures the period of your timer. The value passed in should be in number of clock cycles. 

    The temp variable calculation is to calculate what your period value is in clock cycles based on the input frequency and your desired timer period in microseconds. 

    Lets say you wanted a 50 nanosecond timer and your sysclk is 100MHz (input clock for the timer). 

    1/100MHz = 10 nanoseconds (meaning one clock cycle is 10 nanoseconds). Since in this example the timer is meant for 50 nanoseconds you only need to count 5 clock cycles.

    Therefor, you should just be able to call CPUTimer_setPeriod(cpuTimer, 5) along with the rest of the timer configuration found within the configCPUTimer function.

    Best Regards,

    Marlyn