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

📄 sacm_s530_user.asm

📁 使用GPTC6604做的一个录放音DEMO
💻 ASM
字号:
//========================================================================================
// Progarm: Standard function definition for SACM library V40
// Writen by: Ray Cheng
//
// Lastest modified date: 
//		2000/06/23: first version
//		2000/07/15: modified
//		2000/07/24: modified					for sacmv25.lib
//		2001/10/03: Add more public about queue for sacmv25f.lib
//		2001/11/05: Independent Queue for A2000/S480/MS01 Manual Mode - sacmv25h.lib
//		2001/11/06: Fix volume parameter problem - sacmv25i.lib
//		2001/12/28: add F_SP_SACM_S530_Init_ by Huangsheng
//		2003/01/03: For SACMV32a.lib
//		2003/11/06: For SACMV40a.lib
//
//
// Note: 
//  1. Users are advised to change the user definition only if necessary.
//     Any improper change to other SACM related function may cause library malfunction.  
//  2. This module is inherited Use the SACMVxx.inc,SACMVxx.h,SACMVxx.asm with sacmvxx.lib  
//	3. Provide Open code for sacmVxx.lib
//  4. Please refer to spce.inc for BODY_TYPE definition.
//       This setting affects the configuration of some functions in this file.
//
//========================================================================================
//
.include SPT6604A.inc

//== User definition =====================
.define C_RampDelay 80

.public F_SACM_S530_SendDAC1
.public F_SACM_S530_EndPlay
//.public F_SACM_S530_ISR_On
//.public F_SACM_S530_ISR_Off
.public F_SP_SACM_S530_Init_
.public _SP_RampUpDAC1
.public _SP_RampDnDAC1
.public F_SP_RampUpDAC1
.public F_SP_RampDnDAC1
.define C_SACM_RAMP_DELAY   80



.public _System_Initial;
.public _System_ServiceLoop;
.public F_System_ServiceLoop
.public F_System_Initial;
.external   F_Key_DebounceCnt_Down;
.external   F_Key_Scan_Initial;
.external   F_Key_Scan_ServiceLoop;



.public _USER_S530_SetStartAddr
.public F_USER_S530_SetStartAddr
.public F_USER_S530_GetData

// Speech Table
.external T_SACM_S530_SpeechTable

// Memory

.RAM

.var R_Resouce_BS
.var R_Resouce_DS


.IRAM
.public	R_InterruptStatus;	
.VAR	R_InterruptStatus = 0;

.code

////////////////////////////////////////////////////////
// Function: F_SACM_XXXX_SendDAC1
// Description: send data to DAC1 from library 
//              
// Syntax  : F_SACM_XXXX_SendDAC1
// Destory : R4
// Parameter : R4: 16-bit unsign PCM
// Return    :None
////////////////////////////////////////////////////////
F_SACM_S530_SendDAC1:
	
	[P_Ch0Envelope] = R4;

	retf; 


////////////////////////////////////////////////////////
// Function: F_SACM_XXXX_EndPlay
// Description: call back from kernel when bit stream 
//              decoding is done 
//              
// Syntax  : F_SACM_XXXX_EndPlay
// Destory: R1
// Parameter : None
// Return    : R1: 16-bit unsign PCM
////////////////////////////////////////////////////////
F_SACM_S530_EndPlay:
	push R1 to [SP]; 
	// implemented by designer and SA
	// User can also handle concatenation , Ramp down ant etc.
	nop
	nop
	pop R1 from [SP]; 
	retf; 

////////////////////////////////////////////////////////
// Function: F_SP_SACM_S530_Init_
// Description: Hardware initilazation, System Clock, DAC, INT
//              Called by library
// Syntax  : F_SP_SACM_Init_
// Destory: R1
// Parameter : None
// Return    : None
////////////////////////////////////////////////////////
F_SP_SACM_S530_Init_:
	FIR_MOV OFF;
	INT  OFF;
	R1 = 0x80;               //C_SystemClock;		// CPU Clock setting 49m
	[P_SystemClock] = R1;
    R1 =B_Strong32768|B_Enable32768|B_8KHz;
    [P_TimeBaseSet] = R1;   
//**********from  32768 generate  16khz  interrupt;
//.ifdef  feng
    R1 = 0xD500;                            //Base 32768Hz
	[P_Tmr_Ctrl] = R1	
	R1 = 0xFFFE;                       // 8.192*2k
    [P_TmrA_Data] = R1;                //Set play rate
    [P_TmrA_Load] = R1;
//.endif	
//************************************************	
//------------------------------------    
.ifdef timerover;	
	R1 = 0xd100;    // TimerA CKA=Fosc
	[P_Tmr_Ctrl] = R1;

	R1=   0xFFFF-0xD0 ; //C_A1600_Timer_Setting;	// TimerA setting
	[P_TmrA_Data] = R1;  //r1 = f3ff
	[P_TmrA_Load] = r1;

.endif;               

//*************************************************
    R1 = 0x0700
    [P_DtmfTone] = R1;	//Speech mode, DAC2 as output
    

	R1 = 0xffff;			// no need to clear FIQ here by arthur
	[P_IntClr] = R1; 

	R1 = [P_Int]		//
	R1 |= B_TmrAInt;        //   C_FIQ_TMA			// Enable Timer A FIQ
	[R_InterruptStatus] = R1	//
	[P_Int] = R1		//

    INT IRQ;
	retf

////////////////////////////////////////////////////////
// Function: F_SP_RampDnDAC1
// Description: Ramp down after using DAC to avoid "bow" sound
//              from speaker 
// Syntax  : F_SP_RampDnDAC1
// Destory: R1
////////////////////////////////////////////////////////
_SP_RampDnDAC1: .PROC
F_SP_RampDnDAC1:
	push R1 to [SP]; 
    R1 = [P_Ch0Envelope]; 
    R1 &= 0xffc0; 
    jz ?_Branch_0; 
    
?_Loop_0:  
    call F_SACM_Delay;
    R1 -= 0x0040; 
    [P_Ch0Envelope] = R1;   
    jnz ?_Loop_0; 
    
?_Branch_0:       
    pop R1 from [SP]; 
    retf; 
.ENDP




////////////////////////////////////////////////////////
// Function: F_SP_RampUpDAC1
// Description: Ramp Up before using DAC to avoid "bow" sound
//              from speaker 
// Syntax  : F_SP_RampUpDAC1()
// Destory: R1
////////////////////////////////////////////////////////
_SP_RampUpDAC1: .PROC
F_SP_RampUpDAC1:
	push R1 to [SP]; 
    R1 = [P_Ch0Envelope]; 
    R1 &= 0xffc0; 
    cmp R1, 0x8000;
    jb ?_Loop_0;
    
    je ?_Branch_0;
                
?_Loop_1:
    call F_SACM_Delay; 
    R1 -= 0x0040; 
    [P_Ch0Envelope] = R1; 
    cmp R1, 0x8000; 
    jne ?_Loop_1; 
      
    jmp ?_Branch_0; 

?_Loop_0:
    call F_SACM_Delay;
    R1 += 0x0040; 
    [P_Ch0Envelope] = R1; 
    cmp R1, 0x8000; 
    jne ?_Loop_0; 
    
?_Branch_0:
	pop R1 from [SP]; 
  	retf; 
.ENDP
    

//.if 0	
//-------------------------------------------------------
// Function: F_SACM_Delay
// Description: Provide delay for Ramp up/down 
//              The delay time is adjustable by adjusting C_SACM_RAMP_DELAY
// Destory: R1
//-------------------------------------------------------			
F_SACM_Delay: .proc
    push R1 to [SP]; 
    R1 = C_SACM_RAMP_DELAY; // Ramp Up/Dn delay per step

?_Loop_0:
    R1 -= 0x0001; 
    jnz ?_Loop_0;  
    
    pop R1 from [SP]; 
    retf;
.endp
//.endif 




//****************************************************************
// Function: System initial setting                    
// Input: None
// Output: None
// Syntax:
// 	call F_System_Initial; (in assembly domain)
//  System_Initial(); (in C domain) 	
//****************************************************************
_System_Initial: .proc 
F_System_Initial:
	int off;
   	R1 = 0xffff;
   	[P_IntClr] = R1;
	
	fir_mov off;       
    
    R1 = 0x0000
    [P_Int] = R1;
     
//    call F_Key_Scan_Initial;  // in sp_lib.asm
//   	call F_System_Initial_User_IO; // User define IO
   	retf;
.endp;


//****************************************************************
// Function: I/O initial setting                    
// Input: None
// Output: None
// Syntax:
// 	call F_User_Init_IO; (in assembly domain)
//****************************************************************   
F_System_Initial_User_IO: .proc       
   	 R1 = 0x0000; // IOA[15..0] input
   	[P_IOA_Dir] =    R1;	 
   	r1  = 0xff00;
   	[P_IOA_PullR] = R1;
   	r1  = 0x00FF;
   	[P_IOA_Data] =  R1;       
	    
   	R1 = 0x0000; // IOB[15..0] input
   	[P_IOB_Dir] = R1;	  
  	[P_IOB_Data] = R1;    

   	retf;     
.endp



//****************************************************************
// Function: Main Loop of system                     
// Input: None
// Output: None
// Using:
// 	call F_System_ServiceLoop; (in assembly domain)
//  System_ServiceLoop(); (in C domain) 	
//****************************************************************
_System_ServiceLoop: .proc                  
F_System_ServiceLoop:
//	call	F_Key_DebounceCnt_Down;		// calling debounce subroutine for key scan subroutine
//	call    F_Key_Scan_ServiceLoop;		// calling key scan subroutine 	   
//   	
	   // Add other general service functions here	
   
      
       r1=0x0001;
       [P_WakeUpClr]=r1
   	retf;
.endp;   



//--------------------------------------------------------------------
//-- Procedure: _USER_S530_SetStartAddr
//-- Syntax: USER_S530_SetStartAddr(int)
//-- Parameter: R1 = PlayIndex 
//-- Return: NONE
//-- Description: This API allows users to set the beginning address 
//                to fetch data. This address can be either a ROM address
//                or a external storage address. User would have to modify
//                the function body based on the application's need.    
//--------------------------------------------------------------------
_USER_S530_SetStartAddr:	.proc
F_USER_S530_SetStartAddr:
    //-----------------------
    // defined by user
    //-----------------------
	push R1, R2 to [sp];
	R1 += T_SACM_S530_SpeechTable;
	R1 = [R1];
	R2 = [R1 ++];
	[R_Resouce_BS] = R2;
	R1 = [R1];
	R1 = R1 LSL 4;
	R1 = R1 LSL 4;
	R1 = R1 LSL 2;
	[R_Resouce_DS] = R1;
			
	pop R1, R2 from [sp];
    //-----------------------
	// end of user define area
    //-----------------------
retf
.endp
//--------------------------------------------------------------------
//-- Function: F_USER_S530_GetData
//-- Parameter: R1 = the address to store ()
//              R2 = the to store
//-- Return: Block data (can be a word, a byte or an array)
//-- Description: This function called by library to fetch data blocks 
//                for playback. The Library needs a data block specified
//                by R1,the start address, and R2, the length of the block.
//                Uaser would have to compose the function body 
//                based on the storage type to fulfill this demand from library. 
//--------------------------------------------------------------------
F_USER_S530_GetData:		.proc
    //-----------------------
    // defined by user
    //-----------------------
     //... user implement this interface to get external data
   	push R1, R4 to [SP];  // add by adamcar 
//	SR = [R_Resouce_DS];
	R3 = [R_Resouce_BS];

?L_Get_Loop:
	cmp R2, 0;
	jz ?L_End;
	SR &= (~0xfc00);
	SR |= [R_Resouce_DS];
	R4 = D:[R3++];
	[R1++] = R4;
	R2 -= 1;
	cmp R3, 0;
	jnz ?L_Get_Loop;
	SR += 0x0400;
	R4 = SR & (~0xfc00);	// added by Ray Cheng 2004.04.20
	[R_Resouce_DS] = R4;	// added by Ray Cheng 2004.04.20
//	[R_Resouce_DS] = SR;
	jmp ?L_Get_Loop;

?L_End:
	[R_Resouce_BS] = R3; 
	 
	pop R1, R4 from [SP];
	//-----------------------
	// end of user define area
    //-----------------------
	retf;
.endp


⌨️ 快捷键说明

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