DSP

DSP28027— DELAY_US总结

2019-07-13 10:35发布

很多程序中都会调用延时程序DELAY_US(A),在文件DSP281x_Examples.h中有如下宏定义:
#define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L) DELAY_US(A)必须要在RAM里运行,因此必须使用代码 #ifdef FLASH
// Copy time critical code and Flash setup code to RAM
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files.
  MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
  InitFlash(); // Call the flash wrapper init function
#endif

把程序从flash搬运到ram中运行,否则的话程序在debug模式下正常,但是release模式下能编译通过但是运行会进入非法中断。 具体做法请参考http://blog.sina.com.cn/s/blog_762cf5f80101asmq.html。