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.

TMS320F28020: Issue with CPUTimers

Part Number: TMS320F28020

hi,

 i m getting one strange observation while configure the CPU timers in the TMS320F28020 controller. i did below configuration for timers.but after configuration  i m able to start only CPUTimer0 not CPUtimer1.

after a diagnosis i found that.  Am i getting value "40000" TIM0PeriodValue variable and in TIM1PeriodValue i getting value "0".  i tried with different period value also but i always getting "0 " value in the  "CpuTimer1Regs.PRD.all" register

long TIM1PeriodValue, TIM1PeriodValue =0;

InitCpuTimers();

ConfigCpuTimer(&CpuTimer0, 40, 1000);

ConfigCpuTimer(&CpuTimer1, 40, 1000);

TIM1PeriodValue = CpuTimer1Regs.PRD.all;

TIM0PeriodValue = CpuTimer0Regs.PRD.all;

CpuTimer0Regs.TCR.all = 0x4001;  //start timer

CpuTimer1Regs.TCR.all = 0x4001;  //start timer

 

Can any one help me , why i can't modify the  " CpuTimer1Regs.PRD.all". or im missing somthing in configuration.

void InitCpuTimers()

{

    EALLOW;
    // CPU Timer 0
    // Initialize address pointers to respective timer registers:
    CpuTimer0.RegsAddr = &CpuTimer0Regs;
    // Initialize timer period to maximum:
    CpuTimer0Regs.PRD.all  = 0xFFFFFFFF;
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
    CpuTimer0Regs.TPR.all  = 0;
    CpuTimer0Regs.TPRH.all = 0;
    // Make sure timer is stopped:
    CpuTimer0Regs.TCR.bit.TSS = 1;
    // Reload all counter register with period value:
    CpuTimer0Regs.TCR.bit.TRB = 1;
    // Reset interrupt counters:
    CpuTimer0.InterruptCount = 0;


      CpuTimer1.RegsAddr = &CpuTimer1Regs;
//    CpuTimer2.RegsAddr = &CpuTimer2Regs;
    // Initialize timer period to maximum:
    CpuTimer1Regs.PRD.all  = 0xFFFFFFFF;
//    CpuTimer2Regs.PRD.all  = 0xFFFFFFFF;
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
    CpuTimer1Regs.TPR.all  = 0;
    CpuTimer1Regs.TPRH.all = 0;
//    CpuTimer2Regs.TPR.all  = 0;
//    CpuTimer2Regs.TPRH.all = 0;
    // Make sure timers are stopped:
    CpuTimer1Regs.TCR.bit.TSS = 1;
//    CpuTimer2Regs.TCR.bit.TSS = 1;
    // Reload all counter register with period value:
    CpuTimer1Regs.TCR.bit.TRB = 1;
//    CpuTimer2Regs.TCR.bit.TRB = 1;
    // Reset interrupt counters:
    CpuTimer1.InterruptCount = 0;
//    CpuTimer2.InterruptCount = 0;
}

  • Hi Bipin,

    Ideally, you are configuring PRD in ConfigCpuTimer and reading it back immediately. There shouldn't be an issue.

    Can you change the order of reading and see?

    TIM0PeriodValue = CpuTimer0Regs.PRD.all;

    TIM1PeriodValue = CpuTimer1Regs.PRD.all;

    Can you step in to ConfigCpuTimer  to check if the PRD register is getting updated?

    Thanks, Katta


  • Thanks Katta,

      There is issue with DSP2802x_Headers_nonBIOS.cmd file,  memory mapping was wrong, here with the corrected memory map which  is already available in control suit.

      CPU_TIMER0  : origin = 0x000C00, length = 0x000008     /* CPU Timer0 registers */
      CPU_TIMER1  : origin = 0x000C08, length = 0x000008     /* CPU Timer0 registers (CPU Timer1 & Timer2 reserved TI use)*/
      CPU_TIMER2  : origin = 0x000C10, length = 0x000008     /* CPU Timer0 registers (CPU Timer1 & Timer2 reserved TI use)*/