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.

[参考译文] TMS320F2812:CPU 时钟延迟

Guru**** 2539500 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1158553/tms320f2812-cpu-clock-delay

器件型号:TMS320F2812

大家好、

您能为以下代码提供帮助吗?

 //禁用看门狗
  DisableDog ();
 
  //将 PLLCR 初始化为0xA
  InitPll (0x0a);
 
  //初始化外设时钟
  InitPeripheralClocks();
 
CPU CLK 应为150m
 
空延迟(UINT16延迟时间)
 uint16 i、j;
 
  for (i=0;<delaytime;i++))
  {
  for (j=0;j<6250;j++);
  }

如果 DelayTim=1、程序将延迟41us。 但是、实际上它会延迟1ms。

可以帮帮你吗?

此致、

Marvin

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Marvin、

    问题在于、有几条拆分指令"落后于"您列出的 C 代码、这将导致时间增加。

    我们有一个称为 us_delay 的函数、您应该在 ADC 示例中看到它、它将这些函数以及 CPU 频率考虑在内、以便根据函数的整数输入提供精确的微秒延迟。

    最棒的

    Matthew

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Mattew:

    谢谢你。

    我是否可以向客户提供应用手册作为 US_DELAY 的参考?

    此致、

    Marvin

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    在以下路径中安装 F281x 的工具包后可以找到此文件:C:\tidcs\c28\DSP281x\v111\DSP281x_common\source\

    以下是文件本身 DSP281x_usDelay.asm 的注释

    ;//###########################################################################
    ;//
    ;// FILE:  DSP281x_usDelay.asm
    ;//
    ;// TITLE: Simple delay function
    ;//
    ;// DESCRIPTION:
    ;//  
    ;// This is a simple delay function that can be used to insert a specified
    ;// delay into code.  
    ;// 
    ;// This function is only accurate if executed from internal zero-waitstate
    ;// SARAM. If it is executed from waitstate memory then the delay will be
    ;// longer then specified. 
    ;// 
    ;// To use this function:
    ;//
    ;//  1 - update the CPU clock speed in the DSP281x_Examples.h
    ;//    file. For example:
    ;//    #define CPU_CLOCK_SPEED 6.6667L // for a 150MHz CPU clock speed
    ;//
    ;//  2 - Call this function by using the DELAY_US(A) macro
    ;//    that is defined in the DSP28_Device.h file.  This macro
    ;//    will convert the number of microseconds specified
    ;//    into a loop count for use with this function.  
    ;//    This count will be based on the CPU frequency you specify.
    ;//
    ;//  3 - For the most accurate delay 
    ;//    - Execute this function in 0 waitstate RAM.  
    ;//    - Disable interrupts before calling the function
    ;//      If you do not disable interrupts, then think of
    ;//      this as an "at least" delay function as the actual
    ;//      delay may be longer. 
    ;//
    ;//  The C assembly call from the DELAY_US(time) macro will
    ;//  look as follows: 
    ;//
    ;//  extern void Delay(long LoopCount);                
    ;//
    ;//        MOV   AL,#LowLoopCount
    ;//        MOV   AH,#HighLoopCount
    ;//        LCR   _Delay
    ;//
    ;//  Or as follows (if count is less then 16-bits):
    ;//
    ;//        MOV   ACC,#LoopCount
    ;//        LCR   _Delay
    ;//
    ;//