久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
DSP2812產生三相SPWM波程序
[打印本頁]
作者:
kobe2488
時間:
2019-6-27 15:54
標題:
DSP2812產生三相SPWM波程序
DSP2812產生三相SPWM波,有需要的拿走
單片機源程序如下:
/*
本程序在220V 3400轉 5對級直流無刷電機調試下通過
*/
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
#include "math.h"
#define C_TIME 20
#define pwm_half_per 3750 /*3750 pwm=20khz*//*sytemclk=150MHz*/
/*1875 pwm=40kHz*/
#define pole 2 /*電機的級對數*/
#define timer2_per 60000//234375/* timer2 period with a 1/128 timer prescaler and 150MHz CPUCLK*/
#define PI 3.1415926
unsigned int adc_res;
unsigned int dir=1;
unsigned int ldd=0;
unsigned int PWM_DUTY=2000;
unsigned int I_result[2048];
unsigned int i=0;
unsigned int hall=0x000;
unsigned int time_cnt=C_TIME;
unsigned int hallspeed=0;
unsigned int prehall=0;
unsigned int speed;
unsigned int a=0,b=0,c=0,d=0;
unsigned int displaytime=0;
unsigned int displayflag=0;
unsigned int fc=10000;
unsigned int f=50;
float M=0.9;
unsigned int k=0;
// Prototype statements for functions found within this file.
void init_eva(void);
void eva_timer1_isr(void);
//void init_evb(void);
// Global counts used in this example
void main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio(); // Skipped for this example
// Initialize only GPAMUX and GPBMUX for this test
EALLOW;
// Enable PWM pins
GpioMuxRegs.GPAMUX.all = 0x003F; // EVA PWM 1-6 pins
GpioMuxRegs.GPAQUAL.all=0x0000;
EDIS;
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
// 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
PieVectTable.T1PINT = &eva_timer1_isr;
EDIS;
// Disable CPU interrupts and clear all CPU interrupt flags:
// 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 purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();
EvaRegs.T1CON.all=0x0000;//disable time1
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
init_eva();
// init_evb();
// Step 5. User specific code, enable interrupts:
// Enable PIE group 2 interrupt 4 for T1PINT
PieCtrlRegs.PIEIER2.all = M_INT4;
// Enable CPU INT2 for T1PINT, INT3 for T2PINT, INT4 for T3PINT
// and INT5 for T4PINT:
IER |= M_INT2;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
EvaRegs.EVAIMRA.bit.T1PINT = 1;
EvaRegs.EVAIFRA.bit.T1PINT = 1;
// Just sit and loop forever:
// PWM pins can be observed with a scope.
for(;;)
{
}
}
void init_eva()
{
// EVA Configure T1PWM, T2PWM, PWM1-PWM6
// Initalize the timers
EvaRegs.GPTCONA.bit.TCMPOE = 1;//0
EvaRegs.GPTCONA.bit.T1PIN = 2;//0
// Initalize EVA Timer1
//EvaRegs.T1PR=0.0001;
EvaRegs.T1PR = pwm_half_per; // Timer1 period
EvaRegs.T1CMPR=0;
//EvaRegs.T1CMPR = PWM_DUTY; // Timer1 compare
EvaRegs.T1CNT = 0x0000; // Timer1 counter
EvaRegs.DBTCONA.all=0x0000; //deadband units off
EvaRegs.ACTRA.all =0x0fff; //pwm pin set active high*/
// Enable compare for PWM1-PWM6
EvaRegs.CMPR1=0;
//EvaRegs.CMPR1=PWM_DUTY;
EvaRegs.CMPR2=PWM_DUTY;
EvaRegs.CMPR3=PWM_DUTY;
EvaRegs.COMCONA.all = 0xA600;
EvaRegs.T1CON.all = 0x842;//0x840
// Compare action control. Action that takes place
// on a cmpare event
// output pin 1 CMPR1 - active high
// output pin 2 CMPR1 - active low
// output pin 3 CMPR2 - active high
// output pin 4 CMPR2 - active low
// output pin 5 CMPR3 - active high
// output pin 6 CMPR3 - active low
EvaRegs.DBTCONA.all = 0x1000; // Disable deadband
}
void eva_timer1_isr(void)
{
EvaRegs.EVAIMRA.bit.T1PINT = 1;
EvaRegs.EVAIFRA.all = BIT7;
EvaRegs.ACTRA.all =0x0666;//0x0c02
//EvaRegs.CMPR3=pwm_half_per-200;
//EvaRegs.CMPR1=PWM_DUTY;
//EvaRegs.CMPR2=PWM_DUTY;
EvaRegs.CMPR1=(pwm_half_per/2)*(1+0.9*sin(PI*k/100));
EvaRegs.CMPR2=(pwm_half_per/2)*(1+0.9*sin(PI*k/100+2*PI/3));
EvaRegs.CMPR3=(pwm_half_per/2)*(1+0.9*sin(PI*k/100+4*PI/3));
k++;
if(k==200)
{
k=0;
}
// EvaRegs.CMPR1=PWM_DUTY;
// EvaRegs.CMPR2=PWM_DUTY;
// EvaRegs.CMPR3=PWM_DUTY;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
}
復制代碼
所有資料51hei提供下載:
75448169dsp2812spwm.zip
(422.74 KB, 下載次數: 63)
2019-6-27 15:53 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://m.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
成人国产精品视频
|
婷婷综合视频
|
日韩欧美中文字幕在线观看
|
一区二区中文
|
91丝袜一区在线观看
|
亚洲天堂偷拍
|
日韩免费看片
|
亚洲一区二区三区在线播放
|
欧美日韩一二三
|
免费网站av
|
成人做爰69片免费
|
日韩一级淫片
|
成人欧美在线
|
欧美一级淫片免费视频魅影视频
|
男男巨肉啪啪动漫3d
|
亚洲欧美精品一区二区
|
av黄色在线观看
|
五月激情久久
|
老司机午夜免费精品视频
|
欧美久久久久久久
|
欧美三根一起进三p
|
亚洲精品欧美
|
99久久精品国产一区二区三区
|
黄色av免费观看
|
伊人综合影院
|
交换多p群乱高h文
|
日韩视频在线免费观看
|
伊人久久久
|
一区二区视频在线播放
|
欧美 日韩 国产 成人 在线
|
久久久综合网
|
在线免费观看av网站
|
色综合视频在线观看
|
欲色av
|
在线观看av不卡
|
日本免费一级片
|
亚洲毛片在线
|
www.国产.com
|
国产免费黄色
|
国产一区二区三区在线视频
|
岛国av在线免费观看
|