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.

TMS320F28388D: Title: DEVICE_DELAY_US() Produces Longer Delay Than Expected on TMS320F28388D

Part Number: TMS320F28388D

Tool/software:

Title: DEVICE_DELAY_US() Produces Longer Delay Than Expected on TMS320F28388D

Description:

I'm working on the TMS320F28388D from the 2838x series. I'm observing that the DEVICE_DELAY_US() macro does not produce accurate delays.

Configuration:

  • Device: TMS320F28388D

  • Core: CPU1 (CPU2 is disabled)

  • External Oscillator (XTAL): 25 MHz

    #define DEVICE_OSCSRC_FREQ 25000000U
    
  • System Clock: 200 MHz

    #define DEVICE_SYSCLK_FREQ 200000000U
    

Issue:

When using the DEVICE_DELAY_US(x) macro:

#define DEVICE_DELAY_US(x) SysCtl_delay(((((long double)(x)) / (1000000.0L / \
                              (long double)DEVICE_SYSCLK_FREQ)) - 9.0L) / 5.0L)

I observe the following incorrect delays:

  • DEVICE_DELAY_US(100) produces ~174 µs

  • DEVICE_DELAY_US(1000000) (1 sec) produces ~1.57 seconds

This shows the delay is overestimated by ~57%.

Questions:

  1. Is this macro definition incorrect for the setup above?

  2. How should I correctly calculate the delay count for SysCtl_delay() at 200 MHz SYSCLK?

  3. Could this be caused by wrong assumptions inside SysCtl_delay() (e.g., how many cycles per loop)?

    Thanks in advance for the support.