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.

TMS570 reset when enabling RTI

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

When we configure the RTI of the TMS570, a reset occurs.

The initialisation procedure is provided herafter.

Could you help us to find what kind of mistake we have done?

Regards

Benoit

procedure MARTM_INI_RTI_INIT (pU32_RTI_FREQ_MHZ                          : in TUINT32;
                                 pU32_INIT_STATE_DURATION_US                : in TUINT32) is
      LU32_COMPARE0 : TUINT32;

      -- RTICOMP0
-- UndCC_Begin(All-CallResult), Ignore for this context.
-- UndCC_Begin(All-IdentifierNoOverload)
      LS_RTICOMP0 : TS_RTICOMP0;
      for LS_RTICOMP0'Address use To_Address(K_RTI_BASE_ADDR + 16#50#);

    -- RTITBCTRL
      LS_RTITBCTRL : TS_RTITBCTRL;
      for LS_RTITBCTRL'Address use To_Address(K_RTI_BASE_ADDR + 16#04#);

      -- RTICPUC0
      LS_RTICPUC0 : TS_RTICPUC0;
      for LS_RTICPUC0'Address use To_Address(K_RTI_BASE_ADDR + 16#18#);

      -- RTISETINTENA
      LS_RTISETINTENA: TS_RTISETINTENA;
      for LS_RTISETINTENA'Address use To_Address(K_RTI_BASE_ADDR + 16#80#);

      -- RTIGCTRL
      LS_RTIGCTRL : TS_RTIGCTRL;
      for LS_RTIGCTRL'Address use To_Address(K_RTI_BASE_ADDR + 16#00#);

      -- RTIINTFLAG
      LS_RTIINTFLAG : TS_RTIINTFLAG;
      for LS_RTIINTFLAG'Address use To_Address(K_RTI_BASE_ADDR + 16#88#);
-- UndCC_End(All-CallResult), Ignore for this context.
-- UndCC_End(All-IdentifierNoOverload)

   begin

      ------------------------------------------------------------------------------
      --                         *** RTI Timebase Control ***
      ------------------------------------------------------------------------------
      -- Free running Counter 0 (RTIFRC0) clocked by the internal up counter 0 (RTIUC0)

      LS_RTITBCTRL.TBEXT  := 16#0#;
      ------------------------------------------------------------------------------
      --                         *** RTI Compare Up Counter 0 ***
      -- The compare up counter 0 register holds the value to be compared with prescale counter 0 (RTIUC0).
      -- When the compare shows a match, the free running counter 0 (RTIFRC0) is incremented
      ------------------------------------------------------------------------------
      LS_RTICPUC0.CPUC0     := K_COUNTER_BLOCK_0_PRESCALER - 1;

      -- Write the RTI Compare 0 (RTICOMP0) value to generate an interrupt after TIME_INIT
      LU32_COMPARE0 := pU32_RTI_FREQ_MHZ*pU32_INIT_STATE_DURATION_US;
-- UndCC_NextLine(All-Division). Division by zero impossible here.
      LU32_COMPARE0 := LU32_COMPARE0/(K_COUNTER_BLOCK_0_PRESCALER);
      LS_RTICOMP0.COMP0 := LU32_COMPARE0;

      ------------------------------------------------------------------------------
      --                         *** RTI Global Control ***
      ------------------------------------------------------------------------------
      LS_RTIGCTRL.CNT0EN   := 16#1#;  -- Counter 0 enabled

      -- Clear INT0-2 flags
      LS_RTIINTFLAG.INT0 := 16#1#;
      LS_RTIINTFLAG.INT1 := 16#1#;
      LS_RTIINTFLAG.INT2 := 16#1#;

      ------------------------------------------------------------------------------
      --                         *** RTI Set Interrupt Enable ***
      ------------------------------------------------------------------------------
      LS_RTISETINTENA.SETINT0 := 16#1#;  -- Enables Compare Interrupt 0
      LS_RTISETINTENA.SETINT1 := 16#1#;  -- Enables Compare Interrupt 1
      LS_RTISETINTENA.SETINT2 := 16#1#;  -- Enables Compare Interrupt 2

      -- Enable interrupts for channels 2, 3, 4 and 9 (RTI Compare0, RTI Compare1, RTI Compare2 and GIO high-level)
      LS_REQENASET0.REQENASET0 := 16#21C#;


   end MARTM_INI_RTI_INIT;

end MARTM_INI_RTI_INIT_PK;

  • Hello,
    Since I am not familiar with the language used in your code, what I can suggest is to use HALCoGen to configure RTI and then to follow the steps in HALCoGen generated code.

    Best regards,
    Miro
  • Hi Miro,

    Here is the assembly code generated by our ada compiler for the source code posted by Benoit:

    sub sp, #24
    movw r2, #0xfc50
    movt r2, #0xffff
    str r2, [sp]
    movw r2, #0xfc04
    movt r2, #0xffff
    str r2, [sp, #4]
    movw r2, #0xfc18
    movt r2, #0xffff
    str r2, [sp, #8]
    movw r2, #0xfc80
    movt r2, #0xffff
    str r2, [sp, #12]
    movw r2, #0xfc00
    movt r2, #0xffff
    str r2, [sp, #16]
    movw r2, #0xfc88
    movt r2, #0xffff
    str r2, [sp, #20]
    ldr r3, [sp, #4]
    ldrb r2, [r3, #3]
    bfc r2, 0,1
    strb r2, [r3, #3]
    ldr r2, [sp, #8]
    mov.w r3, 1
    str r3, [r2]
    mul.w r0, r1, r0
    mov.w r0, r0, lsr #1
    ldr r1, [sp]
    str r0, [r1]
    ldr r1, [sp, #16]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 1
    strb r0, [r1, #3]
    ldr r1, [sp, #20]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 1
    strb r0, [r1, #3]
    ldr r1, [sp, #20]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 2
    strb r0, [r1, #3]
    ldr r1, [sp, #20]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 4
    strb r0, [r1, #3]
    ldr r1, [sp, #12]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 1
    strb r0, [r1, #3]
    ldr r1, [sp, #12]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 2
    strb r0, [r1, #3]
    ldr r1, [sp, #12]
    ldrb r0, [r1, #3]
    orr.w r0, r0, 4
    strb r0, [r1, #3]
    add sp, #24
    bx lr

     

    Rgds,

    Antoine

  • What is the status of the system exception status register (SYSESR, 0xFFFFFFE4) immediately after a system reset is generated (before the reset handler has a chance to interrogate and clear the SYSESR)?

    Regards,
    Sunil
  • Hello,

    Do you have some progress with this issue?

    Best regards,

    Miro

  • Hello

    It seems link to CPSR.A register.

    When we set it to 0 in our Boot, there is no more exception.

    I think you can close this post.

    Regards

    Benoit