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

📄 adc.h

📁 非常实用的AD和pwm的ad公司21990dsp芯片的控制源代码
💻 H
字号:
/***************************************************************************************
*                                                                                      *
* Library: Configuration of Analog to Digital Converter                            *
*                                                                                      *
* File: adc.h                                                                       *
*                                                                                      *
* Description: adc include file                                                     *
* Purpose    : Declare library routines ADC block operation             *
*                                                                                      *
* Author     : JC                                                                      *
* Version    : 1.0                                                                     *
* Date       : Mar 2002                                                            *
* Modification History:    None                                                        *
*                                                                                      *
* Embedded Control Systems                                                             *
* Analog Devices Inc.                                                                  *
***************************************************************************************/

/***************************************************************************************
* Constants that need to be defined in main.h:   									   *
* #define ADC_Number_of_samples				=XXXX //can be any positive integer, does not have to be a power of two											   *
***************************************************************************************/

/***************************************************************************************
*                                                                                      *
* Other Libraries Required by this code:                                               *
*                                                                                      *
* None                                                                                 *
***************************************************************************************/

#ifndef ADC_INCLUDED
#define ADC_INCLUDED

/***************************************************************************************
* Routines Defined  in this code                                                     *
***************************************************************************************/
.extern ADC_Init_;
.extern ADC_Scale_;

/***************************************************************************************
* Variables declared in this Module                                                    *
***************************************************************************************/

.extern Offset_0to3;
.extern Offset_4to7;
/***************************************************************************************
* Global Variables Defined                                               *
***************************************************************************************/

/* None */

/***************************************************************************************
*                                                                                      *
* Type:  Macro                                                                         *
*                                                                                      *
* Call: ADC_Init(ADC_Number_of_samples, ADC_EOC_interrupt_label);                                               *
*                                                                                      *
* Initialises the ADC block of the adsp-21990 with offset being calculated over        *
* Then the ADC remains in simultaneous mode											   *
*                                                                                      *
* Inputs  : ADC_Number_of_samples- Number of samples used for calculating the ADC offset*
*          ADC end of conversion interrupt address label                                                                          *
* Ouputs  :	None                                                                   	   *
*                                                                                      *
* Modified:	ar, af, ax0, ay0, ay1, mr,  mx0, my0, sr, px, I4				                                          				   *
*                                                                                      *
***************************************************************************************/

#define ADC_Init(ADC_Number_of_samples, ADC_EOC_int_label)\
	Set_InterruptVector(INT2_ADDR, ADC_EOC_int_label);/* Vector for ADC EOC int*/\
	call ADC_Init_		
	ar = IMASK;
	ay0 = 0x0040;			//enable USR0, USR1
	ar = ar or ay0;
	IMASK = ar;

	
/***************************************************************************************
*                                                                                      *
* Type:  Macro                                                                         *
*                                                                                      *
* Call: ADC_Read(ADC_DATAX, Offset_0to3 or Offset_4to7);                                               *
*                                                                                      *
* Read the value from the ADC block with the offset being taken into account									   *
*                                                                                      *
* Inputs  : ADC_DATAX- Channel number that want to be read, from ADC_DATA0 to ADC_DATA7*
*						representing from VIN0 to VIN7 respectively
*           Offset- Use Offset_0to3 for VIN0 to VIN3, Offset_4to7 for VIN4 to VIN7                                                                           *
* Ouputs  :	Adjusted ADC value stored in AR register                                                                   	   *
*                                                                                      *
* Modified:	ar, ay0				                                          				   *
*                                                                                      *
***************************************************************************************/
	
#define ADC_Read(ADC_DATAX,	Offset)\
	iopg=ADC_Page;\
	ar=IO(ADC_DATAX);\
	ay0=DM(Offset);\
	call ADC_Scale_	
		
#endif



⌨️ 快捷键说明

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