找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 215|回复: 1
打印 上一主题 下一主题
收起左侧

生成双通道带死区的PWM波

[复制链接]
跳转到指定楼层
楼主
ID:1151321 发表于 2025-5-22 19:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
用GPIO1和GPIO2生成双通道PWM波,一般为10Khz,通过修改Duty可以直接进行占空比
#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

Uint16    *ExRamStart = (Uint16 *)0x100000;

void ConfigEPwm(void);
interrupt void EPWM_INT(void);

float Duty;

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
// InitXintf16Gpio();   //zq

   InitEPwm1Gpio();

   Duty=0.5;

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;// 禁用CPU全局中断(防止配置过程中被中断打断)
   InitPieCtrl();// 初始化PIE(外设中断扩展)控制寄存器
   IER = 0x0000;// 清零CPU中断使能寄存器(禁用所有CPU级中断)
   IFR = 0x0000;// 清零CPU中断标志寄存器(清除所有未处理的中断标志)
   InitPieVectTable();// 初始化PIE向量表(存储中断服务函数地址)

   EALLOW;
   PieVectTable.EPWM1_INT=&EPWM_INT;// 将EPWM1中断服务函数地址写入PIE向量表
   EDIS;

   IER |= M_INT3;// 使能CPU的第3组中断(对应ePWM、eQEP等外设中断)

   PieCtrlRegs.PIEIER3.bit.INTx1 = 1;// 使能PIE第3组的第1个中断(即ePWM1中断)

   EINT;// 启用全局中断(允许CPU响应中断)

   ConfigEPwm();

// Step 4. Initialize the Device Peripheral. This function can be
//         found in DSP2833x_CpuTimers.c
  // InitCpuTimers();   // For this example, only initialize the Cpu Timers

// Configure CPU-Timer 0, 1, and 2 to interrupt every second:
// 150MHz CPU Freq, 1 second Period (in uSeconds)

   //ConfigCpuTimer(&CpuTimer0, 150, 1000000);
   //ConfigCpuTimer(&CpuTimer1, 150, 1000000);
   //ConfigCpuTimer(&CpuTimer2, 150, 1000000);
//

评分

参与人数 1黑币 +40 收起 理由
admin + 40 共享资料的奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:609503 发表于 2025-5-23 17:43 | 只看该作者
只有函数调用,没有具体的实现啊。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表