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

📄 codec_processing_isr.asm

📁 adsp21065例程代码 音频处理及其他 adsp2XXX源代码 在Vdsp++下应用
💻 ASM
📖 第 1 页 / 共 2 页
字号:
   a chance to set the TX tag bits.                                                                 /
                                                                                                    /
   JT                                                                                               /
   ADI DSP Applications                                                                             /
   Rev 2.0                                                                                          /
   4/29/99                                                                                          /
                                                                                                    /
****************************************************************************************************/

/* ADSP-21060 System Register bit definitions */
#include 	"def21065l.h"
#include 	"new65Ldefs.h"

/* AD1819 TDM Timeslot Definitions */
#define		TAG_PHASE				0
#define		COMMAND_ADDRESS_SLOT	1
#define		COMMAND_DATA_SLOT		2
#define		STATUS_ADDRESS_SLOT		1
#define		STATUS_DATA_SLOT		2
#define		LEFT					3
#define		RIGHT					4

/* Left and Right ADC valid Bits used for testing of valid audio data in current TDM frame */
#define		M_Left_ADC				12
#define		M_Right_ADC				11
#define		DAC_Req_Left			0x80
#define		DAC_Req_Right			0x40

.GLOBAL		Process_AD1819_Audio_Samples;
.GLOBAL 	Left_Channel_In;
.GLOBAL 	Right_Channel_In;
.GLOBAL 	Left_Channel_Out;
.GLOBAL 	Right_Channel_Out;
.EXTERN		tx_buf;
.EXTERN		rx_buf;
.EXTERN		Stereo_Compressor;

.segment /dm    dm_codec;

/* AD1819a stereo-channel data holders - used for DSP processing of audio data recieved from codec */
.VAR 		Left_Channel_In;
.VAR 		Right_Channel_In;
.VAR		Left_Channel_Out;
.VAR		Right_Channel_Out;
.VAR		ADC_valid_bits;

/* AC'97 audio frame/ISR counter, for debug purposes */
.VAR		audio_frame_timer = 0;


.endseg;

.segment /pm pm_code;

Process_AD1819_Audio_Samples:	
	/* Build Transmit Tag Phase Slot Information */
	r0 = 0x8000;               				/* Set Valid Frame bit 15 in slot 0 tag phase  */	
 	dm(tx_buf + TAG_PHASE) = r0;			/* Write tag to tx-buf ASAP before it's shifted out of SPORT! */	
	r0 = 0;									/* Clear AC97 link Audio Output Frame slots for now */
	dm(tx_buf + COMMAND_ADDRESS_SLOT) = r0;	
	dm(tx_buf + COMMAND_DATA_SLOT) = r0;
	dm(tx_buf + LEFT) = r0;			
	dm(tx_buf + RIGHT) = r0;	
					
check_ADCs_for_valid_data:
    r0 = dm(rx_buf + TAG_PHASE);      		/* Get ADC valid bits from tag phase slot*/
    r1 = 0x1800;                			/* Inspect for valid L/R ADC data */
    r2 = r0 and r1;							/* Mask other bits in tag */
	dm(ADC_valid_bits) = r2;

set_tx_slot_valid_bits:
	r1 = dm(tx_buf + TAG_PHASE);       		/* set tx valid bits based on ADC valid bits info */
	r3 = r2 or r1;        					/* set left/right channel bits in tag, if required */    		
	dm(tx_buf + TAG_PHASE) = r3;			/* Write tag to tx-buf ASAP before it's shifted out of SPORT! */	

check_AD1819_ADC_left:                         		
	BTST r2 by M_Left_ADC;					/* Check Master left ADC valid bit */
	IF sz JUMP check_AD1819_ADC_right;   	/* If valid data then save ADC sample */
	   r6 = dm(rx_buf + LEFT);				/* get Master 1819 left channel input sample */
	   r6 = lshift r6 by 16;   				/* shift up to MSBs to preserve sign in 1.31 format */
	   dm(Left_Channel_In) = r6;			/* save to data holder for processing */

check_AD1819_ADC_right:                        				
	BTST r2 by M_Right_ADC;					/* Check Master right ADC valid bit */
	If sz jump user_applic;      			/* If valid data then save ADC sample */
	   r6 = dm(rx_buf + RIGHT);				/* get Master 1819 right channel input sample */
	   r6 = lshift r6 by 16;   				/* shift up to MSBs to preserve sign in 1.31 format */
	   dm(Right_Channel_In) = r6; 			/* save to data holder for processing */

/* --------------------------------------------------------------------------------------------	*/
/*  user_applic( ) - User Applications Routines	                                                */
/* 	*** Insert DSP Algorithms Here ***                                                          */
/*                                                                                              */
/*  Input L/R Data Streams - DM(Left_Channel_In) DM(Right_Channel_In)                           */
/* 	Output L/R Results     - DM(Left_Channel_Out) DM(Right_Channel_Out)                         */
/*                                                                                              */
/*	These left/right data holders are used to pipeline data through	multiple modules, and       */
/*	can be removed if the dsp programmer needs to save instruction cycles                       */
/*	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       */
/* 	Coding TIP:                                                                                 */
/*	The samples from the AD1819A are 16-bit and are in the lower 16	bits of the the 32-bit      */
/*	word.  They are shifted to the most significant bit positions in order to preserve the      */
/*	sign of the samples when they are converted to floating point numbers. The values are       */
/*	also scaled to the range +/-1.0 with the integer to float conversion                        */
/*	(f0 = float r0 by r1).                                                                      */
/*                                                                                              */
/*	To convert between our assumed 1.31 fractional number and IEEE floating point math,         */
/*	here are some example assembly instructions ...                                             */
/*                                                                                              */
/*		r1 = -31        <-- scale the sample to the range of +/-1.0                             */
/*		r0 = DM(Left_Channel);                                                                  */
/*   		f0 = float r0 by r1;                                                                */
/*		[Call Floating_Point_Algorithm]                                                         */
/*    		r1 = 31;    <-- scale the result back up to MSBs                                    */   
/* 		r8 = fix f8 by r1;                                                                      */
/*		DM(Left_Channel) = r8;                                                                  */
/* -------------------------------------------------------------------------------------------- */

user_applic:
	CALL Stereo_Compressor; 

	/* ---- DSP processing is finished, now playback results to AD1819 ---- */
	
playback_audio_data:
	/* Transmit Left and Right Valid Data every time there the ADCs have valid data */
	r2 = dm(ADC_valid_bits);

tx_AD1819_DAC_left:
	BTST r2 by M_Left_ADC;				/* Check to see if we need to send DAC right sample */
	IF sz JUMP tx_AD1819_DAC_right;   	/* If valid data then transmit DAC sample */		
	r15 = dm(Left_Channel_Out); 		/* get channel 1 output result */
	r15 = lshift r15 by -16;			/* put back in bits 0..15 for SPORT tx */
	dm(tx_buf + LEFT) = r15;			/* output right result to AD1819a Slot 3 */

tx_AD1819_DAC_right:
	BTST r2 by M_Right_ADC;				/* Check to see if we need to send DAC right sample */
	If sz jump tx_done;      			/* If valid data then transmit DAC sample */
	r15 = dm(Right_Channel_Out); 		/* get channel 2 output result */
	r15 = lshift r15 by -16;			/* put back in bits 0..15 for SPORT tx */
	dm(tx_buf + RIGHT) = r15;			/* output right result to AD1819a Slot 4 */	

tx_done:
	r0=dm(audio_frame_timer);			/* get last count */
	rti(db);							/* return from interrupt, delayed branch */
	r0=r0+1;							/* increment count */
	dm(audio_frame_timer)=r0;			/* save updated count */

/* ////////////////////////////////////////////////////////////////////////////////// */ 

.endseg;

⌨️ 快捷键说明

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