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

📄 main.c

📁 许继的2812开发全套驱动程序,很全很实用的.rar
💻 C
字号:
//
//###########################################################################
//
// FILE:	VSI_Control.c
//
// TITLE:	Control Program for Single-Phase Voltage Source Inverter
//
// DESCRIPTION:
//
//          This program is to control single-phase inverter, repetitive control
//          and predictive control method are adopted.
//
//          
//                 
//
//###########################################################################
//
//  Ver | dd mmm yyyy |   Who   | Description of changes
// =====|=============|=========|===============================================
//  0.50| 01 May 2002 | T.CHEN. | for TMX320F2812
//  1.00| 02 Nov 2003 | T.CHEN. | for TMP320F2812
//###########################################################################

// Step 0.  Include required header files
         // DSP28_Device.h: device specific definitions #include statements for
         // all of the peripheral .h definition files.
         // DSP28_Example.h is specific for the given example.  
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#include "IQMathLib.h"




// Serial Communications Interface software module

// Man-Machine Interface software module

//*	 Control software module variable define




volatile struct KEY_VARS KeyVars;
volatile struct SCIB_VARS ScibVars;
volatile struct SCIA_VARS SciaVars;




// Prototype statements for functions found within this file.
interrupt void eva_t2ufint_isr(void);
interrupt void eva_capint1_isr(void);
interrupt void eva_capint2_isr(void);
interrupt void sciarxint_isr(void);
interrupt void scibrxint_isr(void);
interrupt void xnmi_isr(void);

void initvariable(void);	// initialize variables
void disp_main_graph(void);

            char * lpstr  =(char *)0x80000;
            unsigned char ch;
            long int count=0;
extern unsigned char * bmp_ac;
extern unsigned char * bmp_atd; 
extern unsigned char * bmp_dta; 
extern unsigned char * bmp_swon; 
extern unsigned char * bmp_swoff; 
extern unsigned char * bmp_diode; 
extern unsigned char * sineinput;
extern unsigned char * DCinput;
extern unsigned char * DCsupply;
void main(void)
{
	int i;
	int x,y;
	unsigned int key=0;

	(*(char *)(lpstr+1))=0x7c;
	

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO: 
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
   InitGpio();  // Skipped for this example  

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
   DINT;


	

// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.  
// This function is found in the DSP281x_PieCtrl.c file.
   InitPieCtrl();

/*** Copy all FLASH sections that need to run from RAM ***/

// Section ramfuncs contains user defined code that runs from CSM secured RAM
/*   memcpy(	&ramfuncs_runstart,
			&ramfuncs_loadstart,
			&ramfuncs_loadend - &ramfuncs_loadstart);
*/
/*** Initialize the FLASH ***/
//   InitFlash();						// Initialize the FLASH (FILE: SysCtrl.c)
   
// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt 
// Service Routines (ISR).  
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
   InitPieVectTable();	
	
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
   InitPeripherals();

// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:
	
    // Reassign ISRs. 
        // Reassign the PIE vector for T2UFPINT, CAPINT1 , NMI 
        // and T4PINT to point to a different 
        // ISR then the shell routine found in DSP28_DefaultIsr.c.
        // This is done if the user does not want to use the shell ISR routine
        // but instead wants to use their own ISR.  This step is optional:
	
	EALLOW;	// This is needed to write to EALLOW protected registers
	PieVectTable.T2UFINT = &eva_t2ufint_isr;
	PieVectTable.CAPINT1 = &eva_capint1_isr;
	PieVectTable.CAPINT2 = &eva_capint2_isr;
	PieVectTable.RXAINT  = &sciarxint_isr;
	PieVectTable.RXBINT  = &scibrxint_isr;	
	PieVectTable.XNMI    = &xnmi_isr;	
	
	EDIS;       // This is needed to disable write to EALLOW protected registers
            
	// Enable PIE group 3 interrupt 3,5 for T2UFINT,CAPINT1
    PieCtrlRegs.PIEIER3.all = (M_INT3 | M_INT5);
        
	// Enable PIE group 9 interrupt 1,3 for SCIRXINTA, SCIRXINTB
    PieCtrlRegs.PIEIER9.all = (M_INT1 | M_INT3);
	
    // Enable CPU INT3 for T2UFINT, CAPINT1,INT9 for SCIRXINTA,SCIRXINTB:
	IER |= (M_INT3 | M_INT9);

	// Initialize user variable
	initvariable();	
	

	   

	InitLCD1335();

  	disp_main_graph();
  // Enable global Interrupts and higher priority real-time debug events:
 	EINT;   // Enable Global interrupt INTM
	ERTM;	// Enable Global realtime interrupt DBGM
	
	


// Step 6. IDLE loop. Just sit and loop forever:	
	while(1)
		{
			
			
			KickDog(); /* reset watchdog */				
		}; /* endless loop, wait for interrupt */

} 	



// initialize variables
void initvariable(void)
{	
	unsigned long int i;
	KeyVars.top = 0;
	KeyVars.bottom = 0;	
	KeyVars.delay_timer = 101;		


}


void disp_main_graph()
{
	Clear_Lcd();
	
	LCDTextOut(142,10,0,"PBD-4",0);
	LCDTextOut(126,26,0,"不间断电源",0);
	
	LCDBmpOut(8,64,&bmp_swoff,0);

	LCDBmpOut(128,64,&bmp_atd,0);
	
	LCDBmpOut(248,64,&bmp_dta,0);
	
	LCDBmpOut(248,128,&bmp_swon,0);
	 
 	LCDBmpOut(128,128,&bmp_diode,0);
   	LCDBmpOut(368,128,&sineinput,0);
   	LCDBmpOut(368,192,&DCinput,0);
   	LCDBmpOut(248,192,&DCsupply,0);
}

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

⌨️ 快捷键说明

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