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/TMS320C6748: C6748 Timer Clock mode not working

Part Number: TMS320C6748

Tool/software: Code Composer Studio

I am trying to generate a clock using timer2. However, I am not getting any output at the TM64P2_out12 pin. What am I missing in the below code?

#define TMR_PERIOD_LSB32 (0x000000FF)
#define TMR_PERIOD_MSB32 (0x0)

#define TMR_GPDATGPDIR_GPDIRO12 (0x00020000u)

#define TMR_GPDATGPDIR_GPDIRO12_SHIFT (0x00000011u)

#define TMR_GPINTGPEN_GPENO12 (0x00020000u)
#define TMR_GPINTGPEN_GPENO12_SHIFT (0x00000011u)

main(void)
{

PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(4)) = 0x00008844;

TimerClockModeSet(SOC_TMR_2_REGS, TMR_TIMER_BOTH);

TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER12, TMR_PERIOD_LSB32);
TimerPeriodSet(SOC_TMR_2_REGS, TMR_TIMER34, TMR_PERIOD_MSB32);

HWREG(SOC_TMR_2_REGS + TMR_GPDATGPDIR) = TMR_GPDATGPDIR_GPDIRO12;
HWREG(SOC_TMR_2_REGS + TMR_GPINTGPEN) = TMR_GPINTGPEN_GPENO12;

TimerEnable(SOC_TMR_2_REGS, TMR_TIMER_BOTH, TMR_ENABLE_CONT);

 while(1);

}

Looking into regsters' value, I found there is strange thing happening in GPINTGPEN.
GPEN012 in GPINTGPEN has to be set, but actually not. It is always stick to logic 0 and I am not getting why. 

  • Hello,

    Have you taken a look at our timer example in the StarterWare package? See:

    and

    Regards,

    Sahin

  • What is the intent of your code? Are you trying to pulse an external pin with the timer? Are you trying to control the pin using the Timer GPIO function? If so, why not use the GPIO peripheral instead?

    The PINMUX connects the external pin to the GPIO peripheral rather than the Timer.

    PINMUX4 = 0x00008844
    GP1[4],GP1[5],GP1[6],GP1[7]

    The connect the Timer to the external pin, the pinmux setting should be

    PINMUX4 = 0x00008444
    GP1[4],TM64P2_OUT12,GP1[6],GP1[7]

    Unsure why GPINTGPEN is not being read back properly. Perhaps it is not being clocked. The manual would suggest that the Timer is connected to SCR F8. You might have to enable the clock to that part.
  • Hi, Norman. The goal is to output timer2's event onto the TM64P2_OUT12 Pin, but I don't see any out of this pin.
    Yes, you are right . The PINMUX setting is wrong. So I fixed this as you suggested, however, it is still the same.
    For the clock input to the part, as I studied through the manual, I found that timer2 is not controlled by PSC and is fed directly from PLL1 like you mentioned (the Timer is connected to SCR F8). When I tested with starterware timer example code, actually it worked.
    What I am looking at now is that TIM12RS' value in TGCR is logic zero. In the manual, it is said that ' Normal timer counting modes cannot be used when the GPIO mode is enabled -- TIM12RS in the timer global control register (TGCR) cannot be brought out of reset when either GPENO12 or GPENI12 in GPINTGPEN is asserted'. So what is normal timer counting modes? Do you happen to know what this mean?

  • I have never used the timer module in that way. The documentation appears pretty clear. See
    29.1.10 TM64P_OUT Event Support
    Your assessment of the documentation regrarding GPIO mode is probably correct. I would say avoid GPIO mode. I would suggest using StarterWare example as a base. The reset values are

    TCR.CP = 0
    Pulse Mode. TM64P_OUT12 goes active after the timer counter reaches the period. The pulse
    width is determined by PWID12.

    TCR.PWID12 = 0
    TSTAT12 stays active for one timer clock cycle when the timer counter reaches the period.

    The StarterWare example prints out a character every second for 9 characters. You should see a pulse on TM64P_OUT12 every second. Assumes that the PINMUX4 has been setup for TM64P2_OUT12. I don't see any other configuration required to get the signal out .

    If you are using the LCDK, the Timer64P2_OUT12 is used as I2C0 SCL and is connected to several chips. It is pulled up by R86. Using the timer to pulse this line might confuse all the attached I2C devices. Should be no harm in theory.
  • I agree with your idea. I'd better avoid GPIO mode.