dsp28335epwm时基模块
时间: 2023-09-03 15:16:16 浏览: 124
DSP28335EPWM时基模块是德州仪器(Texas Instruments)推出的一种用于数字信号处理器(DSP)控制电机的模块。EPWM代表扩展型脉冲宽度调制(Enhanced Pulse Width Modulation),是一种用于产生高精度PWM信号的技术。
该模块具有多个功能,包括:
1. 高分辨率PWM生成:通过调整PWM的占空比和频率,可以精确控制电机的速度和转矩。
2. 正交编码器接口:可以读取电机的位置反馈信号,实现闭环控制。
3. 事件捕获:可以捕获外部事件,如输入捕获器的上升沿或下降沿,以触发特定操作。
4. 死区发生器:用于防止H桥驱动器中的上下桥臂同时导通,防止电流冲突。
5. 相位补偿:通过控制PWM信号的相位,可以实现电机的高效运行。
使用DSP28335EPWM时基模块,您可以实现对电机的精确控制和监测,适用于各种工业应用中的电机驱动和控制系统。
相关问题
dsp28335 epwm
DSP28335的EPWM模块是其重要的外设接口之一,它提供了多通道、高分辨率、高精度的PWM输出,常被用于驱动电机、控制电源变换器等应用中。DSP28335的EPWM模块提供了6个独立的PWM通道,每个通道都可以配置为不同的工作模式,并且可以通过多种方式触发,例如软件触发、硬件触发、外部同步触发等。此外,EPWM模块还提供了多种保护机制,例如死区保护、过流保护等,以保证系统的稳定性和安全性。
dsp28335epwm互补带死区 DEMO
以下是DSP28335 EPWM模块互补带死区的一个简单DEMO示例:
```c
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
void InitEPwm1(void);
void InitEPwm2(void);
void InitEPwm3(void);
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm1();
InitEPwm2();
InitEPwm3();
EINT;
ERTM;
while(1);
}
void InitEPwm1(void)
{
EPwm1Regs.TBPRD = 600; // Set period to 600 TBCLK counts
EPwm1Regs.TBPHS.bit.TBPHS = 0; // Phase is 0
EPwm1Regs.TBCTR = 0; // Clear counter
EPwm1Regs.CMPA.half.CMPA = 300; // Set duty cycle to 50%
EPwm1Regs.CMPB = 300; // Set duty cycle to 50%
EPwm1Regs.AQCTLA.bit.PRD = AQ_SET; // Set PWM1A on period
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on CMPA up
EPwm1Regs.AQCTLB.bit.PRD = AQ_SET; // Set PWM1B on period
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR; // Clear PWM1B on CMPB up
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // Enable dead-band
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL; // EPWMxA is source for both falling/rising edge delay
EPwm1Regs.DBRED = 50; // Falling edge delay = 50 TBCLKs
EPwm1Regs.DBFED = 50; // Rising edge delay = 50 TBCLKs
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
}
void InitEPwm2(void)
{
EPwm2Regs.TBPRD = 600; // Set period to 600 TBCLK counts
EPwm2Regs.TBPHS.bit.TBPHS = 0; // Phase is 0
EPwm2Regs.TBCTR = 0; // Clear counter
EPwm2Regs.CMPA.half.CMPA = 300; // Set duty cycle to 50%
EPwm2Regs.CMPB = 300; // Set duty cycle to 50%
EPwm2Regs.AQCTLA.bit.PRD = AQ_SET; // Set PWM2A on period
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM2A on CMPA up
EPwm2Regs.AQCTLB.bit.PRD = AQ_SET; // Set PWM2B on period
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR; // Clear PWM2B on CMPB up
EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // Enable dead-band
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
EPwm2Regs.DBCTL.bit.IN_MODE = DBA_ALL; // EPWMxA is source for both falling/rising edge delay
EPwm2Regs.DBRED = 50; // Falling edge delay = 50 TBCLKs
EPwm2Regs.DBFED = 50; // Rising edge delay = 50 TBCLKs
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
}
void InitEPwm3(void)
{
EPwm3Regs.TBPRD = 600; // Set period to 600 TBCLK counts
EPwm3Regs.TBPHS.bit.TBPHS = 0; // Phase is 0
EPwm3Regs.TBCTR = 0; // Clear counter
EPwm3Regs.CMPA.half.CMPA = 300; // Set duty cycle to 50%
EPwm3Regs.CMPB = 300; // Set duty cycle to 50%
EPwm3Regs.AQCTLA.bit.PRD = AQ_SET; // Set PWM3A on period
EPwm3Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM3A on CMPA up
EPwm3Regs.AQCTLB.bit.PRD = AQ_SET; // Set PWM3B on period
EPwm3Regs.AQCTLB.bit.CBU = AQ_CLEAR; // Clear PWM3B on CMPB up
EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // Enable dead-band
EPwm3Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
EPwm3Regs.DBCTL.bit.IN_MODE = DBA_ALL; // EPWMxA is source for both falling/rising edge delay
EPwm3Regs.DBRED = 50; // Falling edge delay = 50 TBCLKs
EPwm3Regs.DBFED = 50; // Rising edge delay = 50 TBCLKs
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
}
```
该示例通过初始化三个EPWM模块来实现互补带死区输出。在每个EPWM模块中,设置了一个周期为600 TBCLK计数的PWM信号,并且通过设置相应的寄存器来启用互补模式和带死区功能。其中,`EPwm1Regs`、`EPwm2Regs`、`EPwm3Regs`分别表示三个EPWM模块的寄存器组。
阅读全文