資源簡介
單相光伏逆變器主程序,包括ePWM,PLL,中斷,ADC等子程序
代碼片段和文件信息
//?He?Yuxuan?Pang?Qifeng
//?Checkin?$Date:?March?6?2010?$
//?Update:?March?28?2010
//###########################################################################
#include?“DSP28x_Project.h“?????//?Device?Headerfile?and?Examples?Include?File
#include?“SPWM.h“
#include?“TFT.h“
#include?“FFT.h“
#define?ADC_CKPS???0x1???//?ADC?module?clock?=?HSPCLK/2*ADC_CKPS???=?25.0MHz/(1*2)?=?12.5MHz
#define?ADC_SHCLK??0xf???//?S/H?width?in?ADC?module?periods????????????????????????=?16?ADC?clocks
#define?VoltProtect?25
#define?CurrentProtect?1.5
#define?VoltProtect_u16?1551
#define?CurrentProtect_u16?687
extern?Uint16?RamfuncsLoadStart;
extern?Uint16?RamfuncsLoadEnd;
extern?Uint16?RamfuncsRunStart;
//?Prototype?statements?for?functions?found?within?this?file.
void?InitSPwm1(void);
void?InitECapture(void);
void?InitECapture2(void);
void?ADCInit(void);
void?SPWMDisable(void);
void?Delay(Uint16?i);
void?DoFullPID(void);
interrupt?void?epwm1_isr(void);
interrupt?void?ecap1_isr(void);
interrupt?void?ecap2_isr(void);
interrupt?void?adc_isr(void);
Uint32?CAP1CAP2Diff;
float32?FreqPhase;
Uint16?Freq_Flag1Freq_Flag2;
Uint16?cnt_AddPhasePolePhase_cnt;
Uint16?Id_REG[128]?Ud_REG[128]?Io_REG[128]?Uo_REG[128]?U_Wave[128];
float32?IdUdIoUoUs;
float32?SumMaxMin;
Uint16?ConversionCountConversionCountWave;
Uint16?ADC_Flagij;
Uint16?MPPT_Flag;
Uint16?Io_u16Ud_u16ProtectStatus=0;
Uint16??display[6]TFT_FlagFFT_Flag;
float32?Ki=0.001Kp=0.02Kd=0IntTerm=0PrevError=0Adjust;
void?main(void)
{
//?Step?1.?Initialize?System?Control:
//?PLL?WatchDog?enable?Peripheral?Clocks
//?This?example?function?is?found?in?the?DSP2833x_SysCtrl.c?file.
InitSysCtrl();
//?Step?2.?Initalize?GPIO:
//?This?example?function?is?found?in?the?DSP2833x_Gpio.c?file?and
//?illustrates?how?to?set?the?GPIO?to?it‘s?default?state.
//?InitGpio();//?Skipped?for?this?example
//?For?this?case?just?init?GPIO?pins?for?ePWM1?ePWM2?ePWM3
//?These?functions?are?in?the?DSP2833x_EPwm.c?file
InitEPwm1Gpio();
InitECap1Gpio();
InitECap2Gpio();
//?Step?3.?Clear?all?interrupts?and?initialize?PIE?vector?table:
//?Disable?CPU?interrupts
DINT;
//?Initialize?the?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?DSP2833x_PieCtrl.c?file.
InitPieCtrl();
//?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?DSP2833x_DefaultIsr.c.
//?This?function?is?found?in?DSP2833x_PieVect.c.
InitPieVectTable();
//?Interrupts?that?are?used?in?this?example?are?re-mapped?to
//?ISR?functions?found?within?t
- 上一篇:電動助力轉向系統建模
- 下一篇:基于VHDL語言的四層電梯控制程序 EDA實驗
評論
共有 條評論