2022年svpwm源程序.docx
《2022年svpwm源程序.docx》由会员分享,可在线阅读,更多相关《2022年svpwm源程序.docx(21页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -/ TI File $Revision: /main/8 $ / Checkin $Date: April 21, 2022 15:41:53 $ /# / / FILE: Example_2833xEPwmUpDownAQ.c / TITLE: 空间电压矢量产生程序SVPWM/ / ASSUMPTIONS: / / This program requires the DSP2833x header files. / / Monitor ePWM1-ePWM3 pins on an oscilloscope
2、as described / below./ / EPWM1A is on GPIO0-5 脚 / EPWM1B is on GPIO1-6 脚 / / EPWM2A is on GPIO2-7 脚 脚 / EPWM2B is on GPIO3-10 / / EPWM3A is on GPIO4-11 脚 / EPWM3B is on GPIO5-12 脚/ /# / $TI Release: DSP2833x/DSP2823x Header Files V1.20 $ / $Release Date: August 1, 2022 $ /#includeDSP28x_Project.h/ D
3、evice Headerfile and Examples Include File/ Prototype statements for functions found within this file.voidInitEPwm1Example void ; 第 1 页,共 11 页 - - - - - - - - - voidInitEPwm2Example void ; voidInitEPwm3Example void ; voidsvpwmGen void ; interruptvoidsvpwm_isr void ; volatilefloat Ualpha,Ubeta; volat
4、ilefloat A,B,C; 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - -名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -volatilefloat T0,T1,T2,T3,T4,T5,T6; volatile float Taon,Tbon,Tcon; float Ua,Ub,Uc; float Ts; int a,b,c; int N= 0,sector= 0; #define TPRD 800 #define Udc 800 void main void / Step 1. Initialize Syste
5、m 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 its default state./ InitGpio; / Skipped f
6、or this example / For this case just init GPIO pins for ePWM1, ePWM2, ePWM3 / These functions are in the DSP2833x_EPwm.c file InitEPwm1Gpio; InitEPwm2Gpio; InitEPwm3Gpio; / Step 3. Clear all interrupts and initialize PIE vector table: / Disable CPU interrupts DINT; / Initialize the PIE control regis
7、ters 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; 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 2 页,共
8、 11 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - - 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 purpos
9、es./ 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 this file. EALLOW; / This is needed to write to EALLOW protected registers PieVect
10、Table.EPWM1_INT = &svpwm_isr; /PieVectTable.EPWM2_INT = &epwm2_isr; /PieVectTable.EPWM3_INT = &epwm3_isr; EDIS; / This is needed to disable write to EALLOW protected registers/ Step 4. Initialize all the Device Peripherals: / This function is found in DSP2833x_InitPeripherals.c / InitPeripherals; /
11、Not required for this example/ For this example, only initialize the ePWM EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; EDIS; InitEPwm1Example; InitEPwm2Example; InitEPwm3Example; EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; EDIS; / Step 5. User specific code, enable interrupts:/ Enable CPU INT3
12、which is connected to EPWM1-3 INT: IER |= M_INT3; / Enable EPWM INTn in the PIE: Group 3 interrupt 1-3 PieCtrlRegs.PIEIER3.bit.INTx1 = 1; 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 3 页,共 11 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -/PieCtrlRegs.PIEIER3.bit.INTx2 = 1; /PieCtrl
13、Regs.PIEIER3.bit.INTx3 = 1;/ 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 optional: for ; asm NOP ; /main 终止/=interruptvoidsvpwm_isr void svpwmGen
14、; / Set Compare valuesEPwm1Regs.CMPA.half.CMPA = Taon; EPwm2Regs.CMPA.half.CMPA = Tbon; EPwm3Regs.CMPA.half.CMPA = Tcon; / Clear INT flag for this timer EPwm1Regs.ETCLR.bit.INT = 1; / adjust duty for output EPWM1A / adjust duty for output EPWM2A / adjust duty for output EPWM3A/ Acknowledge this inte
15、rrupt to receive more interrupts from group 3 PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; voidInitEPwm1Example 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 4 页,共 11 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - - / Setup TBCLK EPwm1Regs.TBPRD = TPRD; / TPRD=800,Period = 1600 TBCLK count
16、s EPwm1Regs.TBPHS.half.TBPHS = 0; / Set Phase register to zero EPwm1Regs.TBCTR = 0x0000; / Clear counter / Setup counter mode EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; / Symmetrical mode EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; /Master module EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW; EPwm1Regs.TBCT
17、L.bit.SYNCOSEL = TB_CTR_ZERO; / Sync down-stream module / Setup TpwmEPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; / Clock ratio to SYSCLKOUTTpwm = 2 x EPwm1Regs.TBCTL.bit.CLKDIV = 5; / 原为 TB_DIV1 , 对于上下计数:TBPRD x TTBCLK Fpwm = 1 / Tpwm /Setup shadowing EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; EPwm1Reg
18、s.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; / load on CTR=Zero EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; / load on CTR=Zero / Set actions EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; / set actions for EPWM1A EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; / Set Dead-bandEPwm1Reg
19、s.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; / enable Dead-band moduleEPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; / Active Hi complementaryEPwm1Regs.DBFED = 50; / FED = 50 TBCLKsEPwm1Regs.DBRED = 50; / RED = 50 TBCLKs/ Interrupt where we will change the Compare ValuesEPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022 svpwm 源程序
限制150内