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.

F28335: problem reading CPU0Timer

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I am reading the CPU timer to measure the frequency of a signal.

The signal is sampled in a ISR and every zero crossing I read the timer value. (I use both a 32bit variable and a 16bit variable)

timer_value32=CpuTimer0.RegsAddr->TIM.all;

timer_value16=CpuTimer0.RegsAddr->TIM.half.LSW;

 

Both instruction gets the correct value the first time the ISR is called, but after that, both variables get 0. I am monitoring the timer value under the registers and it is not correct.

Right now I have no idea what could be causing the problem.

Also, I tried to assign the value reading directly the register (like I would do with the MSP430) but the compiler says that TIMER0TIM is undefined. Am I missing something?

timer_value16=TIMER0TIM; 

 

thanks

Marco

  • Please ignore the last question: TIMER0TIM is not mapped directly this way, I need to use the data structures provided.

  • so, if in the watch window I put

    CpuTimer0.RegsAddr->TIM.all

    and 

    CpuTimer0.RegsAddr->TIM.half.LSW

    I get the correct values the first time the program enters the ISR; after that, the watch window shows 

    "Memory map prevented reading of target memory at 0x05810581@Data"

    I believe this is the reason why my variables have value 0.

    Still not sure how to solve it

    Thanks
  • Hi Marco

    You are accesing the timer via pointer. Make sure that "CpuTimer0.RegsAddr" is constant as watchwindow error makes me think it is not.

    Regards, Mitja

  • Mitja, 

    thanks for your reply.

    CpuTimer0 is defined like this:

    struct CPUTIMER_VARS {

       volatile struct  CPUTIMER_REGS  *RegsAddr;

       Uint32    InterruptCount;

       float   CPUFreqInMHz;

       float   PeriodInUSec;

    };

    so RegsAddr is a pointer. This is the definition in the support libraries provided with controlsuite. 

    I don't know how to access the timer register if not this way.

     

    thanks

     

    Marco

  • Marco ,

    under CCS you can access timer registers through GEL-> Watch CPU Timer Registers.

     also check your watchdog state. is it switched off ?

  • Solved! Thanks Mitja for pointing me in the right direction:

     

    DSP2833x_CpuTimers.h contains both "struct CPUTIMER_VARS" and "struct CPUTIMER_REGS".

    CPUTIMER_VARS has a pointer to a CPUTIMER_REGS, but this cannot be used to read the timer value. It is necessary to use directly a variable of type CPUTIMER_REGS.

    In DSP2833x_CpuTimers.h there are two declaration:

    extern volatile struct CPUTIMER_REGS CpuTimer0Regs;

    extern struct CPUTIMER_VARS CpuTimer0;

    I was trying to use "CpuTimer0.RegsAddr->TIM.all", instead I should have used "CpuTimer0Regs.TIM.all".

     

    Marco

  • Hi Roman,

    thanks but I was trying to get the register value to use it in my program. Watchdog was off. I was accessing the register the wrong way.

    Marco