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.

reload timer0

Hi forum people, I have a question about timer0, need reload them and found that the time consumtion to reload the timer0 is about 900 ns, is too, the code is:

 

GpioDataRegs.GPASET.bit.GPIO2 = 1;

// on GPIO2

ConfigCpuTimer(&CpuTimer0, 150,calculo_resto_ton );

GpioDataRegs.GPACLEAR.bit.GPIO2 = 1;

//Set GPIO down

I measured this reload time in a oscillocope (Lecroy wavesurfer 64Xs).

guillermo

  • Hi Guillermo,

    What is your question?? You have a function-call, which you do not get for free. 900ns seem to be a reasonable time to me.

    Regards

    Andreas

  • Hi Andreas, is posible make a timer0 reload without call the function? is for gain time in my calculus process

    thanks

    guillermo

  • You should not need to completely reconfigure the timer on the run like you are doing.  One and only one full configuration of the timer is necessary to get it running.  However you may want to:

    1) Start/Stop the timer

    2) Reset the timer

    3) Change the period

    The code for these is all short and sweet and should take <100ns or less.  I think I got the code right for the way you are doing it (using CpuTimer0Regs), you may need to adjust this but i am simply just changing timer control registers:

    1) CpuTimer0.RegsAddr->TCR.bit.TSS = 1 (for stop), 0 (for start)

    2) CpuTimer0.RegsAddr->TCR.bit.TRB = 1; //Reset

        CpuTimer0.RegsAddr->TCR.bit.TSS = 0; // Restart

    3) CpuTimer0.RegsAddr->PRD.all  = PERIOD_VALUE;

    Hopefully this helps,

    Tim