📄 f2407bldcpwm.c
字号:
/* ==================================================================================
File name: F2407BLDCPWM.C
Originator: Digital Control Systems Group
Texas Instruments
Description: This file contains source for the Full Compare BLDC PWM drivers for the F2407
Target: TMS320F2407 family
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20: Using DSP2407 v. 1.00 or higher
----------------------------------------------------------------------------------*/
#include <regs240x.h>
#include <F2407BLDCPWM.h>
void F2407_BLDC_PWM_Init(PWMGEN *p)
{ SCSR1|=0x0008; /* Turn EVB Clocks on */
T3PR=p->PeriodMax; /* Init Timer 3 period Register */
T3CON=BLDCPWM_INIT_STATE; /* Init PWM Operation */
ACTRB=0x0fff;
GPTCONB=0x0000;
COMCONB=0x0a200;
MCRC=MCRC|0x007E; /* Set up the full compare PWM pins */
}
void F2407_BLDC_PWM_Update(PWMGEN *p)
{
long Tmp;
int GPR0_BLDC_PWM,tab;
// unsigned int pwmtemp;
/*
// State s1: current flows to motor windings from phase A->B, de-energized phase = C
if (p->CmtnPointer==0)
ACTRB = 0x0f3e;
// State s2: current flows to motor windings from phase A->C, de-energized phase = B
else if (p->CmtnPointer==1)
ACTRB = 0x03fe;
// State s3: current flows to motor windings from phase B->C, de-energized phase = A
else if (p->CmtnPointer==2)
ACTRB = 0x03ef;
// State s4: current flows to motor windings from phase B->A, de-energized phase = C
else if (p->CmtnPointer==3)
ACTRB = 0x0fe3;
// State s5: current flows to motor windings from phase C->A, de-energized phase = B
else if (p->CmtnPointer==4)
ACTRB = 0x0ef3;
// State s6: current flows to motor windings from phase C->B, de-energized phase = A
else if (p->CmtnPointer==5)
ACTRB = 0x0e3f;
*/
// Convert "Period" (Q15) modulation function to Q0
// Tmp = (long)p->PeriodMax*(long)p->MfuncPeriod; // Q15 = Q0*Q15
// Period = (int)(Tmp>>15); // Q15 -> Q0 (Period)
GPR0_BLDC_PWM = p->DutyFunc;
// pwmtemp = (unsigned int)GPR0_BLDC_PWM+1;
// Convert "DutyFunc" or "GPR0_BLDC_PWM" (Q15) duty modulation function to Q0
Tmp = (long)p->PeriodMax*(long)GPR0_BLDC_PWM; // Q15 = Q0*Q15
/* if(GPR0_BLDC_PWM >= 0x07fff)
{
CMPR4 = p->PeriodMax;
CMPR4 = p->PeriodMax;
CMPR4 = p->PeriodMax;
}
else*/
{
GPR0_BLDC_PWM = (int)(Tmp>>15); // Q15 -> Q0
CMPR4 = GPR0_BLDC_PWM;
CMPR5 = GPR0_BLDC_PWM;
CMPR6 = GPR0_BLDC_PWM;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -