⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.dsp

📁 本程序为ad的dsp21990控制芯片程序,其功能是通过传统的PI控制算法来实现对电源的控制,控制程序可以采用.asm也可以采用.C。程序的具体算法和介绍在软件压缩
💻 DSP
字号:
/****************************************************************************************
*										       								*
*  Application: PI control						       *

* File: Main.dsp								       						*
*										       								*
* Description: main program file						       				*
* Purpose    : 									       						*
* 										       								*
* Author     : JC								       						*
* Version    : 1.0								       						*
* Date       : Dec 2001                                                  *
* Modification History:    none							       				*
*										       								*
* Embedded Control Systems							     					*
* Analog Devices Inc.								       					*
****************************************************************************************/

/****************************************************************************************
* Include General System Parameters and Libraries                                      *
****************************************************************************************/

#include <main.h>;
#include <pwm.h>;
#include <pi.h>;

/****************************************************************************************
* Constants defined in this code                                      *
****************************************************************************************/

/*None*/ 

/****************************************************************************************
* Global Routines defined in this code                                      *
****************************************************************************************/
.global	start;

/****************************************************************************************
* Global Variables defined in this code                                      *
****************************************************************************************/
/*None*/

/****************************************************************************************
* Local Variables defined in this code                                      *
****************************************************************************************/
#define PI_SF32 0				// n		

.section/data seg_dmdata;

.VAR PI_Delay32[3] =0x0000, 0x0000, 0x0000;	//[Ik, Uk_M, Uk_L]

.section/pm	seg_pmcode;

.VAR PI_Coef32[2] =0xE101, 0x2000; //kp=.25, wpi=50Hz

/****************************************************************************************
* Start of program code                                      *
****************************************************************************************/


start:

	dmpg1 = 0;					// setting data memory indirect access to accessing internal memory, i.e. page 0
	dmpg2 = 0;
	ijpg  = 0;					// setting indirect jump page to accessing internal memory, i.e. page 0

	dis int;					//disable interrupts

PWM_Init(PWM_Trip_Isr, PWM_Sync_Isr); //initialize PWM blocks and setting up PWM sync and PWM trip interrupts

	ar =0;
	IRPTL = ar;					// clear pending interrupts

	ar = IMASK;
	ay0 = 0x0030;			/* enable USR0 and USR1*/
	ar = ar or ay0;
	IMASK = ar;

	ena int; 					//enable interrupts

	PI32_Init(PI_Delay32, 0x0000);	//initialise PI controller

Main:

	jump Main;

/****************************************************************************************
*PWMSYNC interrupt service routine                                      *
****************************************************************************************/

PWM_Sync_Isr:
	
	iopg = PWM0_Page;	//set io page to PWM page
	ar = 0x0200;		// Write 1 to clear interrupt  
	IO(PWM0_STAT) = ar;


/*	!!!!	pseudo code   !!!!!!

		...
		...
		
		ax0= reference value
		ay0= feedback signal

	!!!!	end of pseudo code							*/


		ena AR_SAT;				// computation of error signal
		ar = ax0 - ay0;
		dis AR_SAT;

	
		PI32(PI_Delay32, PI_Coef32, PI_SF32);	// compute controller output	
	
/*	!!!!	pseudo code   !!!!!!

		output value= sr1;

		...
		...

	!!!!	end of pseudo code							*/

	rti;

/****************************************************************************************
*PWMTRIP interrupt service routine                                      *
****************************************************************************************/

PWM_Trip_Isr:
	
	iopg = PWM0_Page;//set io page to PWM page

	ar = 0x0100;		// W1 to clear PWMTRIP interrupt status  
	IO(PWM0_STAT) = ar;
	nop;// user can implement the PWM trip interrupt in this routine, here no operation is implemented.

	rti;



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -