2308
- 收藏
- 点赞
- 分享
- 举报
HRPWM使用问题
我的程序如下
#include "F28x_Project.h" // Device Headerfile and Examples Include File
//#include "F2837xD_Examples.h" // F2837xD Examples Include File
#include "SFO_V8.h"
#include "math.h"
#define PWM_CH 9 // # of PWM chanels
#define STATUS_SUCCESS 1
#define STATUS_FAIL 0
#define AUTOCONVERT 0 // 1 = Turn auto-conversion ON, 0 = Turn auto-conversion OFF
// Declare your function prototypes here
//---------------------------------------------------------------
void HRPWM_Config(int);
void error(void);
// General System variables - useful for debug
Uint16 UpdateFine, DutyFine, status, CMPA_reg_val, CMPAHR_reg_val, CMPB_reg_val, CMPBHR_reg_val;
int MEP_ScaleFactor; // Global variable used by teh SFO library
volatile struct EPWM_REGS *ePWM[PWM_CH] =
{ &EPwm1Regs, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs, &EPwm4Regs, &EPwm5Regs, &EPwm6Regs, &EPwm7Regs, &EPwm8Regs};
void main(void)
{ // Local variables
int i;
Uint32 temp, temp1;
EALLOW;
InitSysCtrl();
EDIS;
InitEPwmGpio(); // EPWM1A EPWM1B thru EPWM9
DINT; // Disable CPU interrupts *** PIE PIE PIE PIE PIE PIE PIE PIE
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
EALLOW;
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
UpdateFine = 1;
DutyFine = 0;
status = SFO_INCOMPLETE;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
while (status== SFO_INCOMPLETE){ // Call until complete
status = SFO();
if (status == SFO_ERROR) {
error(); // SFO function returns 2 if an error occurs & # of MEP steps/coarse step
} // exceeds maximum of 255.
}
//====================================================================
// ePWM and HRPWM register initialization
//====================================================================
HRPWM_Config(10); // ePWMx target
EALLOW;
for(;;)
{
// Sweep DutyFine as a Q15 number from 0.2 - 0.999
for(DutyFine = 0x2300; DutyFine < 0x2350; DutyFine++)
{
if(UpdateFine)
{
// All the above operations may be condensed into
// the following form:
// EPWM1 calculations
for(i=1;i
CMPA_reg_val = ((long)DutyFine * (*ePWM).TBPRD)>>15;
CMPB_reg_val = ((long)DutyFine * (*ePWM).TBPRD)>>15;
temp = ((long)DutyFine * (*ePWM).TBPRD) ;
temp1 = ((long)DutyFine * (*ePWM).TBPRD) ;
temp = temp - ((long)CMPA_reg_val<<15);
temp1 = temp1 - ((long)CMPB_reg_val<<15);
#if (AUTOCONVERT)
CMPAHR_reg_val = temp<<1; // convert to Q16
CMPBHR_reg_val = temp<<1; // convert to Q16
#else
CMPAHR_reg_val = ((temp*MEP_ScaleFactor)+(0x0080<<7))>>15;
CMPAHR_reg_val = CMPAHR_reg_val << 8;
CMPBHR_reg_val = ((temp1*MEP_ScaleFactor)+(0x0080<<7))>>15;
CMPBHR_reg_val = CMPBHR_reg_val << 8;
#endif
// Example for a 32 bit write to CMPA:CMPAHR
(*ePWM).CMPA.all = ((long)CMPA_reg_val)<<16 | CMPAHR_reg_val; // loses lower 8-bits
// Example for a 32 bit write to CMPB:CMPBHR
(*ePWM).CMPB.all = ((long)CMPB_reg_val)<<16 | CMPBHR_reg_val; // loses lower 8-bits
}
}
else
{
for(i=1;i
(*ePWM).CMPA.bit.CMPA = ((long)DutyFine * (*ePWM).TBPRD>>15);
(*ePWM).CMPB.bit.CMPB = ((long)DutyFine * (*ePWM).TBPRD>>15);
}
}
status = SFO(); // in background, MEP calibration module continuously updates MEP_ScaleFactor
if (status == SFO_ERROR) {
error(); // SFO function returns 2 if an error occurs & # of MEP steps/coarse step
} // exceeds maximum of 255.
} // end DutyFine for loop
} // end infinite for loop
} // end main
void HRPWM_Config(period)
{
Uint16 j;
for (j=1;j
(*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW; // set Immediate load
(*ePWM[j]).TBPRD = period-1; // PWM frequency = 1 / period
(*ePWM[j]).CMPA.bit.CMPA = 4; // set duty 50% initially
(*ePWM[j]).CMPA.bit.CMPAHR = (1 << 8); // initialize HRPWM extension
(*ePWM[j]).CMPB.bit.CMPB =8; // set duty 50% initially
(*ePWM[j]).CMPB.all |= (1 << 8); // initialize HRPWM extension
(*ePWM[j]).TBPHS.all = 0;
(*ePWM[j]).TBCTR = 0;
(*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UP;
(*ePWM[j]).TBCTL.bit.PHSEN = TB_DISABLE;
(*ePWM[j]).TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
(*ePWM[j]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
(*ePWM[j]).TBCTL.bit.CLKDIV = TB_DIV1;
(*ePWM[j]).TBCTL.bit.FREE_SOFT = 11;
(*ePWM[j]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
(*ePWM[j]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
(*ePWM[j]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
(*ePWM[j]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
(*ePWM[j]).AQCTLA.bit.ZRO = AQ_SET; // PWM toggle high/low
(*ePWM[j]).AQCTLA.bit.CAU = AQ_CLEAR;
(*ePWM[j]).AQCTLB.bit.ZRO = AQ_SET;
(*ePWM[j]).AQCTLB.bit.CBU = AQ_CLEAR;
EALLOW;
(*ePWM[j]).HRCNFG.all = 0x0;
(*ePWM[j]).HRCNFG.bit.EDGMODE = HR_FEP; // MEP control on falling edge
(*ePWM[j]).HRCNFG.bit.CTLMODE = HR_CMP;
(*ePWM[j]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
(*ePWM[j]).HRCNFG.bit.EDGMODEB = HR_FEP; // MEP control on falling edge
(*ePWM[j]).HRCNFG.bit.CTLMODEB = HR_CMP;
(*ePWM[j]).HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
#if (AUTOCONVERT)
(*ePWM[j]).HRCNFG.bit.AUTOCONV = 1; // Enable auto-conversion logic
#endif
(*ePWM[j]).HRPCTL.bit.HRPE = 0; // Turn off high-resolution period control.
EDIS;
}
}
void error (void) {
ESTOP0; // Stop here and handle error
}
编译通过,但是调试会出现
Can't find a source file at "E:/git_device_support2/device_support/f2837x/F2837x_internal_testcases/EPwm/SFO_v7_fpu_lib_build/c28/SFO_v7_fpu_lib_build_c28.c"
Locate the file or edit the source lookup path to include its location.
咨询后说可以直接跳过。
但是我单步调试的时候会出现,还无法反馈SFO的值
卡在 while (status== SFO_INCOMPLETE){ // Call until complete
status = SFO();
if (status == SFO_ERROR) {
error(); // SFO function returns 2 if an error occurs & # of MEP steps/coarse step
} // exceeds maximum of 255.
}
也就是SFO();没有变化。
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2017-07-06 15:46:36
-
2021-08-17 19:04:08
-
2020-07-23 09:09:18
-
2017-07-04 21:43:48
-
2015-10-22 14:10:14
-
2017-05-25 17:25:15
-
2015-07-16 17:15:36
-
2018-05-17 18:57:50
-
2020-08-27 14:23:17
-
2018-10-16 10:35:09
-
2017-03-03 15:04:26
-
2019-08-14 13:52:03
-
2024-09-27 13:48:17
-
2016-07-01 18:46:58
-
2023-08-15 11:11:47
-
2019-12-05 16:27:35
-
2022-08-09 14:27:54
-
2017-09-01 17:02:11
-
2018-08-07 08:48:16
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认