中科昊芯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)
{
// Disable the watchdog
DisableDog();
// *IMPORTANT*
// The Device_cal function, which copies the oscillator calibration values
// from Haawking reserved OTP into the appropriate trim registers,
occurs automatically
// in the Boot ROM.
// See the device data manual
// Manual for more information.
(*Device_cal)();
// Select Internal Oscillator 1 as Clock Source (default), and turn off
all unused clocks to
// conserve power.
IntOsc1Sel();
// Initialize the PLL control: PLLCR and DIVSEL
// DSP28_PLLCR and DSP28_DIVSEL are defined in DSC2802x_Examples.h
InitPll(DSP28_PLLCR,DSP28_DIVSEL);
// Initialize the peripheral clocks
InitPeripheralClocks();
}
DSP2803x_Examples.h文件程序如下
#ifndef DSP2803x_EXAMPLES_H
#define DSP2803x_EXAMPLES_H
#ifdef __cplusplus
extern"C" {
#endif
/*-----------------------------------------------------------------------------
Specify the PLL control register (PLLCR)
and divide select (DIVSEL) value.
-----------------------------------------------------------------------------*/
//#define DSP28_DIVSEL 0 // Enable /4 for SYSCLKOUT
#define DSP28_DIVSEL 1 // Disable /4 for SYSCKOUT
//#define DSP28_DIVSEL 2 // Enable /2 for SYSCLKOUT
//#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
//#define DSP28_PLLCR 21
//#define DSP28_PLLCR 20
//#define DSP28_PLLCR 19
//#define DSP28_PLLCR 18
//#define DSP28_PLLCR 17
//#define DSP28_PLLCR 16
//#define DSP28_PLLCR 15
// Uncomment for 120 Mhz devices [120 Mhz = (16MHz
* 15)/2]
//#define DSP28_PLLCR 14
//#define DSP28_PLLCR 13
//#define DSP28_PLLCR 12
//#define DSP28_PLLCR 11
#define DSP28_PLLCR 10
// Uncomment for 80 MHz
devices [80 MHz = (16MHz * 10)/2]
//#define DSP28_PLLCR 9
//#define DSP28_PLLCR 8
//#define DSP28_PLLCR 7
//#define DSP28_PLLCR 0
//PLL is bypassed in this mode
//----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
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
// for a 60MHz CPU clock speed
(SYSCLKOUT)
//#define CPU_RATE 8.333L
// for a 120MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 10.417L
// for a 96MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 12.5L
// for a 80MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 25.000L
// for a 40MHz CPU clock speed
(SYSCLKOUT)
//#define CPU_RATE 41.667L
// for a 24MHz CPU clock speed
(SYSCLKOUT)
//#define CPU_RATE 62.5L
// for a 16MHz CPU clock speed
(SYSCLKOUT)
//#define CPU_RATE 125.000L
// for a 8MHz CPU clock speed
(SYSCLKOUT)
#define CPU_FRQ_120MHZ 1
// 120 Mhz CPU Freq
(16 MHz input clock)
#define CPU_FRQ_96MHZ 0
void OSC_LDO_cal(void);
// The following pointer to a
function call internal oscillators
#define Device_cal (void (*)(void))OSC_LDO_cal
//---------------------------------------------------------------------------
// Include Example Header
Files:
//
#include"DSP2803x_GlobalPrototypes.h" // Prototypes for global functions within
the
#include"DSP2803x_EPwm_defines.h" // Macros used for PWM examples.
#include"DSP2803x_I2c_defines.h" // Macros used for I2C examples.
#include"DSP2803x_Dma_defines.h" // Macros used for DMA examples.
#ifndef DSP28_BIOS
#include"DSP2803x_DefaultISR.h"
#endif
externvoid _DSP2803x_usDelay(uint32 data);
// DO NOT MODIFY THIS LINE.
#define DELAY_US(A) _DSP2803x_usDelay((((longdouble)A * 1000.0L) / (longdouble)CPU_RATE) - 15.0L) // reference range A: 2 ~
34951
#ifdef __cplusplus
}
#endif/* extern
"C" */
#endif
更多回帖