⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsp281x_examples.h

📁 许继的2812开发全套驱动程序,很全很实用的.rar
💻 H
字号:
//###########################################################################
//
// FILE:   DSP281x_Examples.h
//
// TITLE:  DSP281x Device Definitions.
//
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  1.00| 11 Sep 2003 | L.H. | First release.  Seperated example specific headers
//      |             |      |     from the DSP28 peripheral headers.
//      |             |      | Added DSP28_BIOS and DSP28_NONBIOS switches
//      |             |      |     to include or not include the default ISR's 
//###########################################################################

#ifndef DSP281x_EXAMPLES_H
#define DSP281x_EXAMPLES_H


#ifdef __cplusplus
extern "C" {
#endif

#define pwm_frequency 7500  // set pwm1~6 frequency 7.5KHZ
#define pwm_half_per  8000 // HSPCLK/pwm_frequency/2=10000,HSPCLK=SYSCLKOUT=150MHz
#define f_point		  300	// 2*pwm_frequency/50Hz=300


#define INCS0			    *((volatile char *)0x080000)
#define INCS1				*((volatile char *)0x080001)
#define INCS2				*((volatile char *)0x080002)
#define INCS3				*((volatile char *)0x080003)
#define INCS4				*((volatile char *)0x080004)


#define OUTCS0				*((volatile char *)0x080000)
#define OUTCS1				*((volatile char *)0x080001)
#define OUTCS2				*((volatile char *)0x080002)
#define OUTCS3				*((volatile char *)0x080003)
#define LCDDATAADD          *((volatile char *)0x080004)
#define LCDCMDADD           *((volatile char *)0x080005)
#define KEYADD              *((volatile char *)0x080006)

/*
#define OUTCS4				*((volatile char *)0x080004)
#define OUTCS5				*((volatile char *)0x080005)
#define OUTCS6				*((volatile char *)0x080006)
#define OUTCS7				*((volatile char *)0x080007)
#define OUTCS8				*((volatile char *)0x080008)
*/
extern Uint16 ramfuncs_loadstart;
extern Uint16 ramfuncs_loadend;
extern Uint16 ramfuncs_runstart;


#define CPLDOUT1ADD  0X80000
#define CPLDLCDADD   0X80001
#define CPLDLCDDATA  0x80006



#define WAIT_LCD_IDLE delay()
#define LCD_NOP lcd_nop()

/*-----------------------------------------------------------------------------
      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:  CLKIN is a 30MHz crystal. 
 
                In step 1 the user specified PLLCR = 0xA for a 
                150Mhz CPU clock (SYSCLKOUT = 150MHz).  

                In this case, the CPU_RATE will be 6.667L
                Uncomment the line:  #define CPU_RATE  6.667L   
-----------------------------------------------------------------------------*/
#define CPU_RATE    6.667L   // for a 150MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE    7.143L   // for a 140MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE    8.333L   // for a 120MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE   10.000L   // for a 100MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE   13.330L   // for a 75MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE   20.000L   // for a 50MHz CPU clock speed  (SYSCLKOUT)
//#define CPU_RATE   33.333L   // for a 30MHz CPU clock speed  (SYSCLKOUT)
//#define CPU_RATE   41.667L   // for a 24MHz CPU clock speed  (SYSCLKOUT)
//#define CPU_RATE   50.000L   // for a 20MHz CPU clock speed  (SYSCLKOUT)
//#define CPU_RATE   66.667L   // for a 15MHz CPU clock speed  (SYSCLKOUT)
//#define CPU_RATE  100.000L   // for a 10MHz CPU clock speed  (SYSCLKOUT)

//----------------------------------------------------------------------------



//---------------------------------------------------------------------------
// Include Example Header Files:
//

#include "DSP281x_GlobalPrototypes.h"       // Prototypes for global functions within the 
                                            // .c files.

#include "DSP281x_SWPrioritizedIsrLevels.h" // Used for Software Prioritization of ISR's


// Include files not used with DSP/BIOS
#ifndef DSP28_BIOS
#include "DSP281x_DefaultISR.h"
#endif


// DO NOT MODIFY THIS LINE.  
#define DELAY_US(A)  DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)




struct CTR_VARS {
	int reset_lock;	
	int Udc;
	int Udc_offset;
	int Udc_prescale; 		// amplify 2^10 times
	int Udc_uplimit;
	int Udc_lowlimit;
	int Udc_aver;
	int long Udc_sum;		
	
	int Vs;
	int	Vs_offset;
	int Vs_prescale;  		// amplify 2^10 times
	
	int sinwt; 				// sinusoid function
	int coswt;
	int Vs_sinwt_main;		// the peak-value of Vs	
	int long Vs_sinwt_sum;	// used to calculate peak-value of Vs
	
	int Vs_rms_ref;  		// the reference output voltage is Vs_rms_ref*sinwt	
	int long Vs_sum_20ms;	// used to calculate DC component of Vs
	
	int rep[f_point];		// repetitive control variables	
	int Vyk;
	int Vyks1;	
	
	int pid_Vyks1;			// predictive-PID control variables
	int pid_Vyks2;
	
	int	Ic;
	int	Ic_offset; 			// the sample value of analog signal
	int Ic_prescale;  		// amplify 2^10 times
	int	long Ic_sum_20ms;	// used to calculate DC component of Ic
	int Ic_coswt_main;
	int long Ic_coswt_sum;
	
	int Il;
	int	Il_offset; 			// the sample value of analog signal
	int	long Il_sum_20ms;	// used to calculate DC component of Il
	int pianci;
	
	int Il_sinwt_main;		// the peak-value of Il	
	int long Il_sinwt_sum;	// used to calculate peak-value of Il
	
	int factor_tmp;
	int pre_factor;			// feedforward value
	
	int start;	
	int fault;				// indicate the fault status
	int run_led;			// used to control the flash of run-lamp	
	int run_stop;
	
	int pwm_enable;
	int t2ufint_counter;
	int long sum_counter; 	// used to calculate phase
	
	int thirtysecond;
	int KeyValue;
	
	int Udc_low_fault;
	int Udc_high_fault;
	int Il_fault;
	int short_circuit;
	int Vs_fault;
	
	int pianci_rec;
	
};


//** SCI software variable define
struct SCIA_VARS {
	int i;
//	int xxx[5];
};

struct SCIB_VARS {
	int test;
};


struct KEY_VARS {
	char buf[256];
	int  top;
	int  bottom;
	int	 delay_timer;
};

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif  // end of DSP281x_EXAMPELS_H definition


//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -