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.

CCS/TMS570LC4357: Value of Counter

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello,

freq= 500;

void blink(void){
    static unsigned int time;
    time = rtiGetPeriod(rtiREG1,rtiCOMPARE0);
    if(time%freq==0){
        gioSetBit(gioPORTB,6,gioGetBit(gioPORTB,6)^0x01);
    }
}

In HalcoGen i have set my Compare Value to 1000ms. How can i get the current value of my Counter?

Thanks a lot

  • Hello,

    There are two counters in RTI: free running counter (RTIFRCx) and up counter (RTIUCx). The counter values can be determined by reading the respective counter registers or by generating a hardware event which captures the counter value into the respective capture register (RTICAUCx, and RTICAFRCx). x means 0 or 1.
  • Hi,

    a = rtiREG1->CNT[counter].FRCx;

    b = rtiREG1->CNT[counter].UCx;

    If you set the compare value to 2ms, you will get RTI interrupt every 2ms, the frequency is 500. you don't need to compare time and freq manually:

    time = rtiGetPeriod(rtiREG1,rtiCOMPARE0);

       if(time%freq==0){...