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.

RTOS/TMS320C6747: CLOCK module have a time offset in SYS/BIOS

Part Number: TMS320C6747


Tool/software: TI-RTOS

Hi expert,

Customer has a question about CLOCK module in SYS/BIOS.

Hardware:TMS320C6747,50M crystal,DSP run in 300M;

Software:CCS5.5,SYS/BIOS 6.37.5.35,XTOOLS 3.25.6.96

BIOS enable CLOCK、TIMER、TimeStamp,and make sure the input frequency of Timer0/Timer1 is 50M,create a clock before BIOS is boot

Error_init(&eb);
Clock_Params_init(&clkParams);
clkParams.period = 5;
clkParams.startFlag = false;
gs_clk = Clock_create(ClockSwiHandler, 100, &clkParams, &eb);
Assert(NULL != gs_clk);

When this clock start by Clock_start(), use UART to get the TimeStamp for each time it run, and found the time gap isn't the setting 5ms, it's almost 5.005ms.

------------------------------------------------------------------------------------------------------

When using the HWI in Timer1_34 to do the same process.

void timer1_setup(void)
{
static const uint32_t TIMER_PERIOD12 = 50000000u/1000u - 1u;
static const uint32_t TIMER_PERIOD34 = 50000000u/200u - 1u;

tmr1Regs->TCR = 0; 
tmr1Regs->TGCR = 0;

tmr1Regs->TGCR |= 0x04; 
tmr1Regs->TGCR |= 0x03;

tmr1Regs->PRD12 = TIMER_PERIOD12; 
tmr1Regs->TIM12 = 0; 
tmr1Regs->PRD34 = TIMER_PERIOD34; 
tmr1Regs->TIM34 = 0;

tmr1Regs->TCR &= ~0x1000100; 
tmr1Regs->TCR |= 0x800080; 
}

This setting can produce the setting time gap.

When the period don't minus 1:

static const uint32_t TIMER_PERIOD12 = 50000000u/1000u
static const uint32_t TIMER_PERIOD34 = 50000000u/200u;

...

The effort is same with CLOCK module in SYS/BIOS.

So is the CLOCK module in SYS/BIOS need minus 1 when configurated it ?

Thanks,

Wesley.

  • Hi,

    We're looking into this.

    Best Regards,
    Yordan
  • Hello Wesley,

    What is your Clock tickPeriod? Is it the default 1000 usec?

    Best,
    Sahin
  • Hi Sahin,

    Yes, the Clock tickperiod is default.

    Thanks for your help.

    Regards,

    Wesley

  • Let's assume the Clock module is configured to 1ms and you create a new Clock instance (call it foo) to go off every 5 ticks. Let's say you call Clock_start at 10.5 milliseconds after you call BIOS_start. When does foo get called?

    15 (+small delta) ms foo will be called. Two key points here
    - This is because the tick count was 10 when the Clock instance was started. 10 + 5 is 15.
    - There is a small delta
      * Since the kernel might be doing work on the Clock tick (e.g. making a task ready since Task_sleep expired)
      * There might be other Clock instances to process first
      * When the timer interrupt fires, by default a Hwi runs that posts a Swi. The Swi is where all the above work actually occurs. So this adds some overhead.

    20 (+small delta) ms foo will be called.
    25 (+small delta) ms foo will be called.
    ...

    Todd