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

📄 dvr.asm

📁 使用GPTC6604做的一个录放音DEMO
💻 ASM
📖 第 1 页 / 共 2 页
字号:
//;***************************************************************************************** 
// SACM-DVR1600 algorithm with play, stop, pause, resume, volume up, volume down function
// By Arthur Shieh
// Platform: SPCE061A,unSP IDE 1.65, Windows 2000
// Date: 	
//      2000.07.30		: Alpha release for evaluation
//      2000.07.31		:
//
// General Function call:
// void System_Initial(void);		For Hardware, Keyboard scan, see hardware.asm in detail
// void System_ServiceLoop(void);	For Keyboard scan, see key.asm in detail
//
//
// Standard Function call:
// int SP_GetCh(void);		
//	Return values of SP_GetCh() : {0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}
// 
// 
// Function call for SACM-Speed only:
// Syntax: 
//  void SACM_DVR1600_Initial()
//  	Return Value: N/A
//
//  void SACM_DVR1600_Rec(int RceMonitor,int ADC_Channel,int bit_rate)
//		RceMonitor: 
//                   1	: RceMonitorOn  (ADC+DAC output)
//                   0 	: RceMonitorOff (ADC only)
//	
//		ADC Channel: 0  : Microphone
//					 1~7: Line-in 1~7(IOA0~IOA6)
//
//		bit_rate: 0:        	BIT_RATE_10K           		
//				  1:    		BIT_RATE_12K        		
//				  2:			BIT_RATE_14K        		
//				  3:			BIT_RATE_16K        		
//				  4:			BIT_RATE_20K 		    	
//				  5:			BIT_RATE_24K        			
//
// Gptc6604  play DVR  BIT_RATE_12K ~ 20K For Samples Rate 8k
//
//  void SACM_DVR1600_Play(int Speech index, int Channel, int Ramp_Set)
//		Speech index: 
//                   -1				: Manual mode
//                   0 - max index	: Auto Mode
//	
//		Channel: 	1: DAC1 on
//					2: DAC2 on
//					3: DAC1,2 on
//		Ramp_Set:	0: Ramp Up disable/Ramp Dn disable
//					1: Ramp Up enable/Ramp Dn disable
//					2: Ramp Up disable/Ramp Dn enable
//					3: Ramp Up enable/Ramp Dn enable		
//	
//					 
// void SACM_DVR1600_Stop(void);
// 	
// void SACM_DVR1600_Pause(void);
// void SACM_DVR1600_Resume(void);
// 
// void SACM_DVR1600_Volume(int volume index);
//	volume index: {0..15}
//	
// int SACM_DVR1600_Status(void);
//	bit.0 = 0: Idle
//			1: Audio active
//	bit.1 = 0: Play Mode
//			1: Record Mode
//
//  void SACM_DVR1600_Frame_Hop_Init(void);
//  For manual mode forward-backward function, 
//  call to disable internal length count on bit stream.
//
// Note:
//   1. User would need to check out the resource.asm for resource arrangement.
//      The speech table is T_SACM_DVR1600_SpeechTable for DVR1600.
//   2. New manual mode is demonstrated, which will work with sacm_user.asm.
//      Old falshion queue manipulation manual mode is not supported in this 
//      version.
//   3. For new manual mode, user have to handle the memory address and data 
//      acquisition through F_USER_DVR1600_GetData, _USER_SetStartAddr  	
//   4. The RAM taken by library can be shared by declaring ORAM section, 
//      "OVERLAP_DVR1600_RAM_BLOCK:   .Section        .ORAM". 
//      Please check out IDE menu--> Project-->Setting--> Section for details.	 
//   5. Both forground service loop and background service loop are supported.	
//   6. Data rate of SACM-DVR1600 can be 10/12/14/16/20/24Kbps and
//			the algorithm will select it automatically.	
//   7. Please check out the sacm.asm for details of initial function, interrupt setting, 
//      and timer setting. 					  
//;*****************************************************************************************

.external   F_SACM_S530_ServiceLoop;
.external   F_System_ServiceLoop;
.external   R_SACM_S530_Play_Flag;
.external   F_SACM_S530_Initial;
.external   F_System_Initial
.external   F_SACM_S530_Play;
.external    F_USER_S530_SetStartAddr;
.external   F_SP_GetCh;
.external   F_SACM_S530_Stop;
.external   F_SACM_S530_Pause;
.external   F_SACM_S530_Resume;
.external   F_SACM_S530_Volume
.external    F_ISR_Service_SACM_S530;





.external F_SACM_DVR1600_Initial
.external F_SACM_DVR1600_Rec
.external F_SACM_DVR1600_Play
.external F_SACM_DVR1600_Stop
.external F_SACM_DVR1600_Volume
.external F_SACM_DVR1600_Pause
.external F_SACM_DVR1600_Resume
.external F_SACM_DVR1600_Status
.external F_SACM_DVR1600_ServiceLoop         // Service Loop for foreground
.external F_SACM_DVR1600_ServiceLoop_ISR     // Service Loop for background
.external F_ISR_Service_SACM_DVR1600_FG      // ISR service for foreground
.external F_ISR_Service_SACM_DVR1600_BG      // ISR service for background

.external F_SACM_DVR1600_Frame_Hop_Init      //  For Manual Forward-backward, 
.external F_WriterWord,F_ReadWord,F_FlashTest

.external T_SACM_DVR1600_SpeechTable,SinTab1024,FlashAddrHi
.external __RES_OUT_HASC_2_ENC_sa,F_MassErase
.define _FILE_VAR

.include var.inc
.include spt6604a.inc

.external  _InitLCD,F_Display_ASCII_Character,Character_Position
.public _FIQ,_IRQ1,_IRQ2,_IRQ3,_IRQ4,_IRQ5,_IRQ6,_IRQ7

.ram 
.var		RW_DebounceReg	
.VAR		RW_KeyBufOld;           
.VAR		RW_KeyCode;        
.VAR		RW_Flag
.var		RW_Length
.Var		RW_Address


.define Manual			0					
.define Auto			1
.VAR  SpeechIndex;
.VAR  SpeedIndex;				
.VAR  VolumeIndex;			
.VAR  Mode;


.const  B_RecordBeginAddr  =  0x10
.public R_Resouce_BS
.public R_Resouce_DS
.var R_Resouce_BS
.var R_Resouce_DS
.var	RW_Long
.code
.public _main
_main:
				R1 = 0
				R2 =0x3FC
				BP =R2
	?ClearSram:
				[bp--]	= R1
				test	R5,0xFFF
				jnz		?ClearSram
				[bp]	= R1
				R1 =B_10M+B_FoscDivBy4
				[P_SystemClock] =R1

				R1 =B_10M // 			this EV_B Clock is 25MHz
				[P_SystemClock] =R1
	
			    R1 =B_Enable32768+B_Strong32768+B_128Hz+B_8KHz
				[P_TimeBaseSet] = R1;                   		
				r1 =	0x0000
				[P_IOA_Dir] = r1			//Set IOA as input port
				[P_Ch0Envelope] = r1
				r1 =	0x00FF
				[P_IOB_Dir] = r1			//Set IOB as output ports
				[P_IOC_Dir] = r1			//Set IOC as output ports	
				r1 =	0xFF00
				[P_IOA_PullR] = r1			//Enable the pull-up resistor for IOA0~IOA4

				R3 = 0xd100
				[P_Tmr_Ctrl] = R3   	// clock is 25MHz
				R4 = 0xFFFF-0xc9   	// 0x103  is 12k;  0x138 is 10k
								//0xc4 is 16k     ;0x186 is 8k  0x30d is 4k
							
				//clock 29MHz/8
				//0x1c4 8k 0x192  9k 0x16a 10k  0x149 11k  0x12e 12k
				// c9 18K
				[P_TmrA_Data] = R4
				[P_TmrA_Load] = R4
		
				R1 = B_T128HzInt
				[P_Int] = R1
				r1 =	0x55aa
				[P_Watchdog_Clr] = r1			//Reset watchdog
				Int IRQ,FIQ

//for Debug
//		Call	F_FlashTest            //  Test Flash SPR1024
//		JMP		PlayLoop
//debug end 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
MainLoop:
				 R1 =    0x55AA;                        
		        [P_Watchdog_Clr] = R1;
				call	F_KeyScand
				R1 = [RW_KeyCode]
				test    R1,0xFF
				JZ		MainLoop
				test	R1,0x3         // IOA0,IOA1 Record and Play, IOA2 play internal Rom Data
							   
				JZ		?next0
				goto	?L_StartRecord
		?next0:	
				test	r1,0x4
				jz		?next1
				goto	?L_PlayInternalROM
		?next1:
				goto		?L_PlayS530





////////////////////////////////////////////////
//         keyscand and record loop
///////////////////////////////////////////////
?L_StartRecord:
		R1 = 0
		[RW_Flag] = R1
		CALL	F_SACM_DVR1600_Initial;
		call	F_Record_Initial
		r1 = 0;
		r2 = 0;
		r3	=	1			//bit rate 12kbps		
		//r3  =3;			// bit rate 16kbps
		call		F_SACM_DVR1600_Rec;		//call DVR1600 start record;
?l_RecordMainLoop1:	
		 R1 =  0x55AA;                        
        [P_Watchdog_Clr] = R1;
        
		call    F_SACM_DVR1600_ServiceLoop;	
		R1 = [RW_Flag]
		test	R1,C_EndAddrFlag   // the buffer have been over
		JNZ	   ?ExitRecordLoop
		call	F_KeyScand
		R1 = [RW_KeyCode]
		test    R1,0xFF
		JZ		?l_RecordMainLoop1
?ExitRecordLoop:
        call		F_SACM_DVR1600_Stop;
?l_RecordMainLoop2:	
		 R1 =    0x55AA;                        
        [P_Watchdog_Clr] = R1;
		call    F_SACM_DVR1600_ServiceLoop;	
		R1 = [RW_Flag]
		test	R1,C_RecEndFlag
		JZ		?l_RecordMainLoop2
////////////////////////////////////////////////
//         keyscand and play Record loop
///////////////////////////////////////////////
		R1 = [RW_Length]
		[RW_Long] = R1

?l_PlayRecordLoop:		
		R1 = 0
		[RW_Flag] = R1
		call	F_Play_Initial
		r1 = 15;
		call		F_SACM_DVR1600_Volume;			// set Volume ,15 max;
		r1 = -1;
		r2 = 3;
		R3 = 3
		call		F_SACM_DVR1600_Play;
?PlayRecordLoop:
		r1 =	0x55aa
		[P_Watchdog_Clr] = r1						//Reset watchdog
        call    F_SACM_DVR1600_ServiceLoop;			//write data from ADC to SDARM;
		R1 = [RW_Flag]
		Test R1, C_EndAddrFlag
        JNZ		?AutoStopPlayRecord
		call	F_KeyScand
		R1 = [RW_KeyCode]
		test    R1,0xFF
		JZ		?PlayRecordLoop
?ExitPlayLoop:
		call	F_SACM_DVR1600_Stop
		GoTo		MainLoop
?AutoStopPlayRecord:

⌨️ 快捷键说明

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