中科昊芯Start_DSC28034PNT DELAY_US问题
本次测试本来准备弄一个LCD12864显示,结果程序没有报错的情况下,下进开发板没有任何反应,经过多次测试,发现是DELAY_US()函数有问题。每次调用此函数,程序就会进入跑飞状态,经过多次尝试,也无法解决这一问题。最后询问技术人员,同样程序在他那边调试没问题,但是我这边没法运行,经过技术人员远程调试,最后终于跑起来了,但是他也不知道问题出在哪里。过一段时间,同样的程序,我下进去又无法运行,不稳定。
程序编辑器版本:Haawking-IDE-V2.1.6和Haawking-IDE-V2.1.7版本都尝试过,都不行。
窗口页面:
1、在DELAY_US();函数处设置断点
2、然后点击单步运行,进入以下界面
3、在上边界面一直点击单步运行,最后会出现下边这一界面,然后程序卡死
程序如下:
#include"dsc_config.h"
#include<syscalls.h>
#include"IQmathLib.h"
Uint16 i;
int main(void)
{
InitSysCtrl(); //Initializes the System Control registers to a known state.
DINT;
InitPieCtrl();
IER=0x0000;
IFR=0x0000;
InitPieVectTable();
EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; /GPIO功能,GPIO34是D401的灯/
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; /配置GPIO34为输出模式/
EDIS;
while(1){
GpioDataRegs.GPBCLEAR.bit.GPIO34=1;
for(i=500;i>0;i--)
{
DELAY_US(1000);
}
GpioDataRegs.GPBSET.bit.GPIO34=1;
for(i=500;i>0;i--)
{
DELAY_US(1000);
}
}
return 0;
}
时钟配置程序如下:
void InitSysCtrl(void)
{
DisableDog();
occurs automatically
(*Device_cal)();
all unused clocks to
IntOsc1Sel();
InitPll(DSP28_PLLCR,DSP28_DIVSEL);
InitPeripheralClocks();
}
DSP2803x_Examples.h文件程序如下
#ifndef DSP2803x_EXAMPLES_H
#define DSP2803x_EXAMPLES_H
#ifdef __cplusplus
extern"C" {
#endif
#define DSP28_DIVSEL 1
* 15)/2]
#define DSP28_PLLCR 10
devices [80 MHz = (16MHz * 10)/2]
Specify the clock rate of the CPU (SYSCLKOUT)
in nS.
Take into account the input clock
frequency and the PLL multiplier
selected in step 1.
Use one of the values provided, or define
your own.
The trailing L is required tells the
compiler to treat
the number as a 64-bit value.
Only one statement should be uncommented.
Example 1: 120 MHz devices:
CLKIN is a 16 MHz crystal or
internal 16 MHz oscillator
In step 1 the user specified
PLLCR = 15 DIVSEL=2 for a
120 MHz CPU clock (SYSCLKOUT =
120 MHz).
In this case, the CPU_RATE
will be 8.333L
Uncomment the line:
#define CPU_RATE 8.333L
Example 2: 80 MHz devices:
CLKIN is a 16 MHz crystal or
internal 16 MHz oscillator
In step 1 the user specified
PLLCR = 10 DIVSEL=2 for a
80 MHz CPU clock (SYSCLKOUT =
80 MHz).
In this case, the CPU_RATE
will be 16.667L
Uncomment the line:
#define CPU_RATE 16.667L
-----------------------------------------------------------------------------*/
#define CPU_RATE 16.667L
(SYSCLKOUT)
(SYSCLKOUT)
(SYSCLKOUT)
(SYSCLKOUT)
(SYSCLKOUT)
#define CPU_FRQ_120MHZ 1
(16 MHz input clock)
#define CPU_FRQ_96MHZ 0
void OSC_LDO_cal(void);
function call internal oscillators
#define Device_cal (void (*)(void))OSC_LDO_cal
Files:
#include"DSP2803x_GlobalPrototypes.h"
the
#include"DSP2803x_EPwm_defines.h"
#include"DSP2803x_I2c_defines.h"
#include"DSP2803x_Dma_defines.h"
#ifndef DSP28_BIOS
#include"DSP2803x_DefaultISR.h"
#endif
externvoid _DSP2803x_usDelay(uint32 data);
#define DELAY_US(A) _DSP2803x_usDelay((((longdouble)A * 1000.0L) / (longdouble)CPU_RATE) - 15.0L)
34951
#ifdef __cplusplus
}
#endif
#endif