久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
DSP28335郵箱使用代碼,已測試可用
[打印本頁]
作者:
heartyeah2018
時間:
2017-9-22 10:05
標題:
DSP28335郵箱使用代碼,已測試可用
有需要的童鞋請下載
SP3Muc_ccs5.3_test2MW
下載:
SP3Muc_ccs5.3_test2MW_20150707.rar
(361.38 KB, 下載次數: 13)
2017-9-22 10:05 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
/*==============================================================================*
* Copyright(c) Future Power Technology Co. Ltd. ALL RIGHTS RESERVED
*
* Product : Main control board of 3MW modular switch power
* File name : main.c
* Purpose : Main function and interrupt function include cup timer0 and pwm1
* underflow.
*
* History:
* Date Version Author Note
* 2015-04-24 V1.0 Heaton Created.
*
*==============================================================================*/
/*===========================Include header files===============================*/
#include "GlobalVariableRefs.h"
#include "GlobalVariableDefs.h"
#include "Main.h"
#include "FunctionCall.h"
/*========================Prototype statements for functions====================*/
interrupt void Epwm1_Int_isr(void);
interrupt void Epwm1_Tz1_isr(void);
void Task1ms(void);
void Task2ms(void);
void Task5ms(void);
void Task10ms(void);
void Task50ms(void);
void InitXintf(void);
void InitI2C(void);
void ECANComm(void);
/*================================Macro definition==============================*/
//1/3
#define INV_3 0.3333333
//Run from RAM or FLASH selection with cmd file changed maunually /////////!!!!!!!!!!!
#define FLASH_TYPE 1
//Debug model///////////////!!!!!!!!!
#define DEBUG_MODE 2 //0:Voltage and current closed loop 1:Current closed loop 2:Open loop
/*===========================Global variables in this file======================*/
int16 i161msCount = 0; //Counter of 1ms in main interrupt of 100us/10KHz
int16 i163TmainCount = 0; //Counter of 3 times of main interrupt(71.4us/14KHz)
int16 i163TmainFlag = 0; //Flag of 214.2us period
float32 f32CurADSum = 0; //Current vaule sum from CPLD in 71.4us
//Periodic task structure definition
//Add periodic task array in function list
//and responsible identification in ID list
//Array definition in sub member:run flag, timer, period, fucntion
static PRD_TSK PrdTskList[] =
{
{0, 1, 1, Task1ms},
{0, 1, 2, Task2ms},
{0, 1, 5, Task5ms},
{0, 1, 10, Task10ms},
{0, 1, 50, Task50ms},
//Add task array here...
};
typedef enum PRDTSKID
{
TASK_1ms,
TASK_2ms,
TASK_5ms,
TASK_10ms,
TASK_50ms,
//Add task ID here...
PRDTSK_MAX //Number of periodic tasks
} PRD_TSK_ID;
/*=============================================================================*
* Function: main
* Purpose : Initialization and main loop
* Input:
* void
* Output:
* void
* Calls:
* System and peripheral initialization functions
*
* Called by:
* void
*============================================================================*/
void main(void)
{
Uint16 i;
//Initialize System Control:PLL, WatchDog, enable Peripheral Clocks
InitSysCtrl();
// Disable CPU interrupts
DINT;
//Initialize the PIE control registers to their default state.
InitPieCtrl();
//Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
//Initialize the PIE vector table with pointers to the shell ISR
InitPieVectTable();
//Interrupt configuration:
EALLOW;
//PieVectTable.TINT0 = &Cpu_Timer0_isr; //CPU timer0 interrupt
PieVectTable.EPWM1_TZINT = &Epwm1_Tz1_isr; //EPWM1 tz1 interrupt
PieVectTable.EPWM1_INT = &Epwm1_Int_isr; //EPWM1 int interrupt
EDIS;
//Device peripheral initializaiton
InitXintf(); ///////!!!!!Initialize XINTF tbd...
InitSci(); ///////!!!!!//Initialize the SCIA&SCIB tbd...
InitECan(); //Initialize the ECANA&ECANB
InitI2C(); //Initialize the I2C module
InitPWM(PWM_PERIOD,PWM_DEADBAND); //Initialize the EPWM1 only for interrupt
InitGpio(); //GPIO configure for other use///////////////!!!!!!!! tbd........
////////////!!!!!!!!!!!!!!1
#if FLASH_TYPE
//Copy all FLASH sections that need to run from RAM
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); //////!!!!!!!!!for debug
//Initialize the FLASH
InitFlash(); //////!!!!!!!!!for debug
#endif
/////////////!!!!!!!!!!!111111
//Algorithm initial
ParaInitTrans(); //User defined parameters, variables and structures initialization
//Enable interrupt:
IER |= (M_INT2 | M_INT3);
PieCtrlRegs.PIEIER2.bit.INTx1 = 1;// Enable epwm1 tz int in the PIE: Group 2 interrupt 1
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;// Enable epwm1 int in the PIE: Group 3 interrupt 1
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
//EepTskInit(); ///////!!!!!Initialization must be after global interrupt is enabled
//Main loop
while(1)
{
for(i = 0; i < PRDTSK_MAX; i++)
{
if(PrdTskList[i].u16RunFlag == 1)
{
PrdTskList[i].TaskHook(); //Run the function
PrdTskList[i].u16RunFlag = 0; //Clear the flag for next running loop
}
}
}
}
/*================================function end================================*/
/*=============================================================================*
* Function: Epwm1_Int1_isr
* Purpose : Main period interrupt of 71.4us/14KHz,
* module period
* current read from CPLD 71.4us
* current PI regulation 71.4*3=214.2us
* ECAN 71.4*3=214.2us
* Input:
* AD_UDCOUT
* Output:
* pi_cur.f32Out
* PrdTskList[i].u16RunFlag
* Calls:
* void
* Called by:
* void
*============================================================================*/
interrupt void Epwm1_Int_isr(void)
{
Uint16 i, u16PwmCmp, u16PwmCmpBoost;
float32 f32BuckDutyTmp, f32BoostDutyTmp, f32Tmp;
//Count for 3*71.4=214.2us
i163TmainCount++;
if(i163TmainCount >= 3)
{
i163TmainCount = 0;
i163TmainFlag = 1;
}
//AD convertion
ADMeasure();
//214us module
if(i163TmainFlag == 1)
{
//Average value calculation
f32UdcOut = f32UdcOutSum * INV_3;
f32IL[0] = f32ILSum[0] * INV_3;
f32IL[1] = f32ILSum[1] * INV_3;
f32IL[2] = f32ILSum[2] * INV_3;
//f32CurADSum = (f32IL[0] + f32IL[1] + f32IL[2]);
f32UdcOutSum = 0;
f32ILSum[0] = 0;
f32ILSum[1] = 0;
f32ILSum[2] = 0;
/////////////!!!!!!!!!!!!!!!!!
#if(DEBUG_MODE == 0) //Two closed loop
f32Debug1 += 0.2;
if(f32Debug1 >= f32UdcInRef)
{
f32Debug1 = f32UdcInRef;
}
//Voltage PI regulation
pi_vol.f32Ref = f32Debug1 * INV_VOL_BASE;
pi_vol.f32Fdb = f32UdcOut * INV_VOL_BASE;
//Current PI regulation
pi_cur1.f32Ref = pi_vol.f32Out;
//////////////!!!!!!!!!!!!1for debug
//pi_cur1.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur1.f32Fdb = f32IL[0] * INV_CUR_BASE;
pi_cur2.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur2.f32Fdb = f32IL[1] * INV_CUR_BASE;
pi_cur3.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur3.f32Fdb = f32IL[2] * INV_CUR_BASE;
if(MSW.bit.RUNNING)
{
pi_vol.calc(&pi_vol);
pi_cur1.calc(&pi_cur1);
pi_cur2.calc(&pi_cur2);
pi_cur3.calc(&pi_cur3);
}
else
{
pi_vol.f32Ui = 0;
pi_vol.f32Out = 0;
pi_cur1.f32Ui = 0;
pi_cur1.f32Out = 0;
pi_cur2.f32Ui = 0;
pi_cur2.f32Out = 0;
pi_cur3.f32Ui = 0;
pi_cur3.f32Out = 0;
f32Debug1 = 0;
f32Debug2 = 0;
}
#endif
#if(DEBUG_MODE == 1) //Current closed loop
f32Debug1 += 0.2;
if(f32Debug1 >= 5)
{
f32Debug1 = 5;
}
//Current PI regulation
//////////////////////!!!!!!!!!!for debug
//pi_cur1.f32Ref = f32Debug1 * INV_CUR_BASE;
pi_cur1.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur1.f32Fdb = f32IL[0] * INV_CUR_BASE;
pi_cur2.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur2.f32Fdb = f32IL[1] * INV_CUR_BASE;
pi_cur3.f32Ref = u16EcanCurRef * INV_CUR_BASE;
pi_cur3.f32Fdb = f32IL[2] * INV_CUR_BASE;
if(MSW.bit.RUNNING)
{
pi_vol.calc(&pi_vol);
pi_cur1.calc(&pi_cur1);
pi_cur2.calc(&pi_cur2);
pi_cur3.calc(&pi_cur3);
}
else
{
pi_vol.f32Ui = 0;
pi_vol.f32Out = 0;
pi_cur1.f32Ui = 0;
pi_cur1.f32Out = 0;
pi_cur2.f32Ui = 0;
pi_cur2.f32Out = 0;
pi_cur3.f32Ui = 0;
pi_cur3.f32Out = 0;
f32Debug1 = 0;
f32Debug2 = 0;
}
#endif
#if(DEBUG_MODE == 2) //Open loop
f32Tmp = (float32)u16EcanCurRef / 150;/////////////for debug
f32Debug1 += 2e-5;
if(f32Debug1 >= f32Tmp)
{
f32Debug1 = f32Tmp;
}
/*if(f32Debug1 >= 0.8)
{
f32Debug1 = 0.8;
}*/
if(MSW.bit.RUNNING)
{
pi_vol.calc(&pi_vol);
pi_cur1.calc(&pi_cur1);
pi_cur2.calc(&pi_cur2);
pi_cur3.calc(&pi_cur3);
}
else
{
pi_vol.f32Ui = 0;
pi_vol.f32Out = 0;
pi_cur1.f32Ui = 0;
pi_cur1.f32Out = 0;
pi_cur2.f32Ui = 0;
pi_cur2.f32Out = 0;
pi_cur3.f32Ui = 0;
pi_cur3.f32Out = 0;
f32Debug1 = 0;
f32Debug2 = 0;
}
pi_cur1.f32Out = f32Debug1;
#endif
//PWM cmpr update
if(pi_cur1.f32Out > DUTY_BOOST_START)
{
if(pi_cur1.f32Out > 1)
{
f32BuckDutyTmp = 1;
}
else
{
f32BuckDutyTmp = pi_cur1.f32Out;
}
f32BoostDutyTmp = pi_cur1.f32Out - DUTY_BOOST_START;
}
else
{
f32BuckDutyTmp = pi_cur1.f32Out;
f32BoostDutyTmp = 0;
}
u16PwmCmp = (Uint16)(f32BuckDutyTmp * PWM_PERIOD);
u16PwmCmpBoost = (Uint16)(f32BoostDutyTmp * PWM_PERIOD);
EPwm1Regs.CMPA.half.CMPA = u16PwmCmp; //Buck1
EPwm4Regs.CMPA.half.CMPA = u16PwmCmpBoost; //Boost1
u16BuckDuty = (Uint16)(f32BuckDutyTmp * 100);
u16BoostDuty = (Uint16)(f32BoostDutyTmp * 100);
//ECAN communication
ECANComm();
//DA convertion for debug
DAConverter();
i163TmainFlag = 0 ; //Clear flag for next loop
} //214us end
////////////////!!!!!!!!!!!!!!!!!
//EPwm4Regs.AQCTLA.all = 0x002A;
//AQCTL assignment
if(MSW.bit.RUNNING)
{
EPwm1Regs.AQCTLA.all = AQCTL_RUN_STATE;
///////////////!!!!!!!!!!!!for debug
//EPwm4Regs.AQCTLA.all = AQCTL_RUN_STATE;
if(pi_cur1.f32Out > DUTY_BOOST_START)
{
EPwm4Regs.AQCTLA.all = AQCTL_RUN_STATE;
}
else
{
EPwm4Regs.AQCTLA.all = AQCTL_STOP_STATE;
}
}
else
{
EPwm1Regs.AQCTLA.all= AQCTL_STOP_STATE;
EPwm2Regs.AQCTLA.all= AQCTL_STOP_STATE;
EPwm3Regs.AQCTLA.all= AQCTL_STOP_STATE;
EPwm4Regs.AQCTLA.all= AQCTL_STOP_STATE;
EPwm5Regs.AQCTLA.all= AQCTL_STOP_STATE;
EPwm6Regs.AQCTLA.all= AQCTL_STOP_STATE;
}
//1ms counter
i161msCount++;
if(i161msCount>=14)
{
i161msCount=0;
//Periodic task process
for(i = 0; i < PRDTSK_MAX; i++)
{
PrdTskList[i].i16Timer--;
if(PrdTskList[i].i16Timer <= 0)
{
PrdTskList[i].u16RunFlag = 1; //Enbable function run
PrdTskList[i].i16Timer = PrdTskList[i].u16Period_ms;
}
}
} //1ms count end
// Clear INT flag for this timer
EPwm1Regs.ETCLR.bit.INT = 1;
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP3;
}
/*================================function end================================*/
/*=============================================================================*
* Function: Task1ms
* Purpose : Periodic task fucntion of 1ms
* Input:
* void
* Output:
* void
* Calls:
* CtrLogic()
* Monitor()
* Called by:
* main()
*============================================================================*/
void Task1ms(void)
{
Uint16 u16OutCurTmp;
//Fault and alarm
Monitor();
//Control logic, this function must be after Monitor()
CtrLogic();
//Filter
//Output current filter
/////////////!!!!!!!!!!!!!!need to modify
u16OutCurTmp = (Uint16)(CUR_BASE * pi_cur1.f32Fdb);
R_u16FltCurOut += (Uint16)((u16OutCurTmp - R_u16FltCurOut) * OUT_CUR_FLT_CON);
}
/*================================function end================================*/
/*=============================================================================*
* Function: Task2ms
* Purpose : Periodic task fucntion of 2ms
* Input:
* void
* Output:
* void
* Calls:
* CtrCmdSrc()
* Called by:
* main()
*============================================================================*/
void Task2ms(void)
{
//Contrl source
CtrCmdSrc();
}
/*================================function end================================*/
/*=============================================================================*
* Function: Task5ms
* Purpose : Periodic task fucntion of 5ms
* Input:
* void
* Output:
* void
* Calls:
* void
* Called by:
* main()
*============================================================================*/
void Task5ms(void)
{
//DO process
//DOFunc();
//I2CEEFunc();
}
/*================================function end================================*/
/*=============================================================================*
* Function: Task10ms
* Purpose : Periodic task fucntion of 10ms
* Input:
* void
* Output:
* void
* Calls:
* void
* Called by:
* main()
*============================================================================*/
void Task10ms(void)
{
//DO process
//DOFunc();
//I2CEEFunc();
/////////////!!!!!!!!!!!!485 for debug
RS485IntHost();
}
/*================================function end================================*/
/*=============================================================================*
* Function: Task50ms
* Purpose : Periodic task fucntion of 50ms
* Input:
* void
* Output:
* void
* Calls:
* ParaInputTrans()
* ParaListTrans()
* Called by:
* main()
*============================================================================*/
void Task50ms(void)
{
//Parameter input transformation
ParaInputTrans();
//Parameter display transformation
ParaListTrans();
}
/*================================function end================================*/
/*=============================================================================*
* Function: Epwm1_Tz1_isr
* Purpose : EPWM1 tz1 interrupt when IPM sends a fualt output signal
* Input:
* void
* Output:
* void
* Calls:
* void
* Called by:
* void
*============================================================================*/
interrupt void Epwm1_Tz1_isr(void)
{
// Clear INT flag for this timer
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
// Acknowledge this interrupt to receive more interrupts from group 2
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP2;
}
/*================================function end================================*/
/*===========================================================================*
* End of file.
*===========================================================================*/
復制代碼
作者:
vampireaaa
時間:
2017-9-25 14:51
學習一下
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
日本在线网址
|
久久久久久久久久久久久九
|
久久夜视频
|
精品一区二区不卡
|
午夜激情小视频
|
久久国产福利
|
国产91丝袜
|
日韩在线h
|
亚洲国产成人精品女人久久久
|
综合精品久久久
|
二区在线观看
|
毛片1
|
国产日韩精品一区二区三区
|
国产免费一区二区
|
天天插天天射天天干
|
97伦理
|
欧美中文一区
|
av在线免费网
|
欧美亚洲国产一区二区三区
|
伊人伊人伊人
|
91精品欧美久久久久久久
|
国产日韩久久
|
日本a v在线播放
|
天天色天天射天天干
|
天天天操操操
|
一区二区视频在线
|
成人在线a
|
在线婷婷
|
www.青青草
|
一级做a爰片久久毛片免费看
|
能看的av
|
久久免费精品
|
欧美无乱码久久久免费午夜一区
|
啪啪免费网
|
亚洲最大成人综合
|
成人在线免费观看
|
浮生影院免费观看中文版
|
www.青娱乐
|
精品日本久久久久久久久久
|
国产精品久久久久久久久久久久冷
|
日本不卡一区二区三区
|