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.

RM46L852: RTI Counter

Part Number: RM46L852

Hi,

I need to setup the RTI 0 Counter, so that tne Freescale FRC is incrementet every millisecond and i can get the Time in millsecond since programm start.

I'm using the following Code, but the FRCx is incremeted only many seconds, why ?

main()

{
/* USER CODE BEGIN (3) */


rtiInit();

rtiStartCounter(rtiCOUNTER_BLOCK0);


while(1)
{   

     printf("FRCx: %d CPUCx:%d\n",(int) rtiREG1->CNT[rtiCOUNTER_BLOCK0].FRCx,(int)rtiREG1->CNT[rtiCOUNTER_BLOCK0].CPUCx);

}

/* USER CODE END */

return 0;
}

  • Hi Armin,

    There is no mistake in your configuration and for above configuration the FRC register will increment for every 1mSec only.

    You didn't mention how you measured, i guess it is mistake in your measurement. In while loop you are continuously printing the FRC register value right(You are not printing after increment of FRC register), so same value might print multiple times and it doesn't mean it is incrementing for seconds.

    I just did small experiment with your configuration 

    On above code you can see on change of FRC value i am toggling one GIO and i scope that gio pin

    See the result and it is incrementing for every 1msec only.

    I am attaching my code for your reference and please go through it.

    RTI_1msec_TEST.zip

    --

    Thanks & Regards,
    Jagadish.

  • Hi Jagadish,

    I measured with my watch, as you can see in the screenshot the FRC increments only after some printfs.

  • Hi Armin,

    FRC increments only after some printfs.

    Yes, it will increment after some printfs because you are printing FRC register value in in while(1) continuously and even not verifying its increment. And obviously the while(1) loop execution time will be way less than 1msec right, so it will print FRC register value each time loop gets executed.

    And this is not the right way to calculate the time of increment. As i told you please use a GPIO for this purpose.

    Or at least try to print FRC register value after changing like the code i shared to you, in that case you will get printf for every 1msec and you will get 1000 values for every 1Sec.

    --

    Thanks & Regards,
    Jagadish.

  • Hi Jagadish,

    yes, you are right, I forgett that the USB Communication has some Buffers, I assumed that the Printf is blocking and takes some milliseconds, ... with tne GPIO I get the same results.

    Thanks, regards

    Armin