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.

TMS320C5517: Why does my timer seem to not exist?

Part Number: TMS320C5517

I have a TMS320C5517 EVM development board made by Spectrum Digital Incorporated. I want to use timer 0, but I was surprised to see in register.h that the timer registers don't exist. Does anybody know why? I added them myself like this

#define T0CR            *(ioport volatile uint16_t *)0x1810
#define TIM0PRD1        *(ioport volatile uint16_t *)0x1812
#define TIM0PRD2        *(ioport volatile uint16_t *)0x1813
#define TIM0CNT1        *(ioport volatile uint16_t *)0x1814
#define TIM0CNT2        *(ioport volatile uint16_t *)0x1815
#define TISR            *(ioport volatile uint16_t *)0x1C3E

but when I put in a break point and look at the register values in the Code Composer Studio register view then the registers have default values. Does anybody know what's wrong? My source can be found below.

 .sect "vector"
 .def _VECSTART
 .ref _timerIsr
 .ref _dmaIsr
 .ref _gpioIsr
 .ref _communicationIsr
 .ref _c_int00
 .ref _dummyIsr
 .align  256

; Interrupt vector definitions
_VECSTART:
_RST:      .ivec    _c_int00, USE_RETA ; Reset / Software Interrupt #0
NMI:       .ivec    no_isr           ; Nonmaskable Interrupt
INT0:      .ivec    no_isr           ; External User Interrupt #0
INT1:      .ivec    no_isr           ; External User Interrupt #1
TINT0:     .ivec    _timerIsr        ; Timer #0 / Software Interrupt #4
PROG0:     .ivec    no_isr           ; Programmable 0 Interrupt
UART:      .ivec    no_isr           ; IIS #1 Receive Interrupt
.
.
. #define SYSTEM_CLK_FREQ_Hz ((uint32_t)196000000) uint16_t configAndRestartTimer(uint16_t delayMs, uint16_t timerIntCallbackPtr) { T0CR = 0x8000; // Enable timer uint32_t timerFreq = SYSTEM_CLK_FREQ_Hz / 8192; uint32_t numNeededTimerTicks = timerFreq/(1000 * ((uint32_t)delayMs)); TIM0PRD2 = (uint16_t)(numNeededTimerTicks >> 16); // Set period of timer TIM0PRD1 = (uint16_t)(numNeededTimerTicks >> 0); // Set period of timer TIM0CNT2 = 0; // Reset the count value TIM0CNT1 = 0; // Reset the count value TISR = 1; // Timer 0 interrupt is routed to CPU non-maskable interrupt (NMI). T0CR = (((uint16_t) 1) << 15) | // Enable timer (((uint16_t) 0xC) << 2) | // 8192 as prescalar. This will give a timer freq of 196 MHz / 8192 = 23.926 kHz (((uint16_t) 0) << 1) | // Auto-reload is disabled (((uint16_t) 1) << 0); // Start the counter return 0; } interrupt void timerIsr(void) { UART_SW_Tx_ONLY_transmitNullTermString("\r\ntimerIsr"); }
  • Hi,

    I've notified the sw team. Please state which SDK are you using or is this a bare metal code?

    Best Regards,
    Yordan
  • I don't know from which SDK the register.h file comes from, it could potentially be several years old. However, I don't mind adding those lines of code myself, but I'm more concerned about my code not working properly.
  • user4463194,

    We currently support the C55x CSL which can be found here http://software-dl.ti.com/dsps/dsps_public_sw/dsps_swops_houston/C55X/latest/index_FDS.html hence the reason for asking which SW package you are using.

    Taking a look at the CSL timer driver, there are definitions for Timer0

    /********************************************************************* 
    * Timer Registers (0x1800 - 0x1896)
    **********************************************************************/
    #define IOPORT_REG_TIMER0_CONTROL            (IOPORT_REGISTER(0x1810))
    #define IOPORT_REG_TIMER0_PERIOD_0           (IOPORT_REGISTER(0x1812))
    #define IOPORT_REG_TIMER0_PERIOD_1           (IOPORT_REGISTER(0x1813))
    #define IOPORT_REG_TIMER0_COUNTER_0          (IOPORT_REGISTER(0x1814))
    #define IOPORT_REG_TIMER0_COUNTER_1          (IOPORT_REGISTER(0x1815))

    Are you in a position to try these examples to see if it works for you?

    C:\ti\c55_lp\c55_csl_3.08\ccs_v6.x_examples\rtc

    Lali

  • If I include those 5 lines of #defines then I get the following build error:

    error #138: expression must be a modifiable lvalue

    I have modified my code a bit, but it still doesn't work (I get no timer interrupt) and the register values don't change in the Register view in the debug window. When I break execution and look at the register values I see the following:

    TIMER0

       TCR           0x0000

       TIMPRD1 0xFFFF

       TIMPRD2 0x0000

       TIMCNT1 0xFFFF

       TIMCNT2 0x0000

       TINSF       0xFFFF

    I can't change the values either in the debugger Register view, it's like those registers are read only .

    #define SYSTEM_CLK_FREQ_Hz   ((uint32_t)196000000)
    
    #define T0CR            *(ioport volatile uint16_t *)0x1810
    #define TIM0PRD1        *(ioport volatile uint16_t *)0x1812
    #define TIM0PRD2        *(ioport volatile uint16_t *)0x1813
    #define TIM0CNT1        *(ioport volatile uint16_t *)0x1814
    #define TIM0CNT2        *(ioport volatile uint16_t *)0x1815
    #define TISR            *(ioport volatile uint16_t *)0x1C3E
    
    uint16_t configAndRestartTimer(uint16_t delayMs, uint16_t timerIntCallbackPtr) {
        PCGCR1 &= ~(0x0400);
        T0CR = 0x8000;                                     // Enable timer
        uint32_t timerFreq = SYSTEM_CLK_FREQ_Hz / 8192;
        uint32_t numNeededTimerTicks = timerFreq/(1000 * ((uint32_t)delayMs));
        TIM0PRD2 = (uint16_t)(numNeededTimerTicks >> 16);  // Set period of timer
        TIM0PRD1 = (uint16_t)(numNeededTimerTicks >> 0);   // Set period of timer
        TIM0CNT2 = 0;                                      // Reset the count value
        TIM0CNT1 = 0;                                      // Reset the count value
        IER0 |= 0x0010;
    
        T0CR = (((uint16_t) 1)     << 15) |                // Enable timer
               (((uint16_t) 0xC)   << 2)  |                // 8192 as prescalar. This will give a timer freq of 196 MHz / 8192 = 23.926 kHz (timer period: 41.8 microseconds)
               (((uint16_t) 0)     << 1)  |                // Auto-reload is disabled
               (((uint16_t) 1)     << 0);                  // Start the counter
    }
    
    interrupt void timerIsr(void) {
        UART_SW_Tx_ONLY_transmitNullTermString("\r\ntimerIsr");
    }
  • user4463194,

    Unsure why you are seeing that error.

    Just so that we are on the same page, could you please try to run the GPT example that's in the CSL I referenced above?

    Its located at C:\ti\c55_lp\c55_csl_3.08\ccs_v6.x_examples\gpt\CSL_GPTExample

    This uses timer0 as highlighted in the code. Want to know if thie example works on your setup.

    Lali