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

📄 sacmv32.asm

📁 电子词典的设计开发
💻 ASM
📖 第 1 页 / 共 3 页
字号:
//////////////////////////////////////////////////////
// SACM_dependent functions 
//////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////////////  
// Function: _SP_GetResource
// Description: Get data from resource(ROM area)
// Syntax:  int SP_GetResource(int Addr, int Page)
// Output:  R1: data to read
// Destory: R1
//////////////////////////////////////////////////////////////////  
////////////////////////////////////////////////////////////////// 
// Function: Get data from resource(ROM area)
// 	int SP_GetResource(int Addr, int Page)
//////////////////////////////////////////////////////////////////  
_SP_GetResource:	.PROC
		push bp to [sp] 
		bp = sp + 1 
		
		r1 = [bp+3] 					// Address
		r2 = [bp+4] 					// Page
		
		r2 = r2 lsl 4 					// Prepare Page for SR
		r2 = r2 lsl 4 
		r2 = r2 lsl 2 
		
		sr &= 0x03f 					// Change Page
        r2 |=sr 						//
        sr = r2 						//
  
  		r1 = D:[r1] 					// Get data
       
		pop	 bp from [sp] 
		retf 
		.ENDP 
//........................................
F_SP_GetResource:
		r2 = r2 lsl 4 					// Prepare Page for SR
		r2 = r2 lsl 4 
		r2 = r2 lsl 2 
		
		sr &= 0x03f 					// Change Page
        r2 |=sr 						//
        sr = r2 						//
  
  		r1 = D:[r1] 					// Get data
	  	retf


////////////////////////////////////////////////////////////////// 
// Function: Delay
// 	void SP_Delay()
//////////////////////////////////////////////////////////////////  
_SP_Delay:	.PROC
F_SP_Delay:
		// User define
		retf 
		.ENDP



//////////////////////////////////////////////////////
// SACM initial functions
//////////////////////////////////////////////////////	
.public F_SP_SACM_A1600_Init_
.PUBLIC F_SP_SACM_A2000_Init_
.PUBLIC F_SP_SACM_S530_Init_
.PUBLIC F_SP_SACM_S480_Init_
.PUBLIC F_SP_SACM_S240_Init_
.public F_SP_SACM_S200_Init_

.PUBLIC F_SP_SACM_MS01_Init_
.PUBLIC F_SP_PlayMode0_
.PUBLIC F_SP_PlayMode1_    
.PUBLIC F_SP_PlayMode2_  
.PUBLIC F_SP_PlayMode3_   

.PUBLIC F_SP_SACM_DVR_Init_
.PUBLIC F_SP_SACM_DVR_Rec_Init_
.PUBLIC F_SP_SACM_DVR_Play_Init_

//----------------------------------------------------
// A1600
//----------------------------------------------------	
///////////////////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of SACM_A1600_Initial() 
//			or F_SACM_A1600_Initial:
// Note: The following functions are the partial code of original
//			initial subroutine. (H/W setting part) 
//
//	Ex: F_SACM_A1600_Initial:
//			...
//			call F_SP_SACM_A1600_Init_	: S480/S240/MS01 is same
//			...
//			retf
////////////////////////////////////////////////////////////////////////////////

F_SP_SACM_A1600_Init_:	
		R1 = C_SystemClock;             // 24MHz, Fcpu=Fosc
        [P_SystemClock]=R1           	//  Frequency 20MHz
        R1 = 0x0030                     // TimerA CKA=Fosc/2 CKB=1 Tout:off
        [P_TimerA_Ctrl] = R1			// Initial Timer A
        R1 = C_A1600_Timer_Setting                  	// 16K
        [P_TimerA_Data] = R1 
        R1 = 0x00A8                     // Set the DAC Ctrl
        [P_DAC_Ctrl] = R1
        R1 = 0xffff
        
        [P_INT_Clear] = R1          	// Clear interrupt occuiped events
        R1 =0x0000						// 
        
        .if BODY_TYPE == SPCE061A
        R1 = [P_INT_Mask]		//
        .endif
       // .if BODY_TYPE == SPCE500A
      //  R1 = [R_InterruptStatus]		//
      //  .endif        
        
        R1 |= C_FIQ_TMA					// Enable Timer A FIQ
        //R1 |= C_IRQ4_1KHz
      //  [R_InterruptStatus] = R1		//
        [P_INT_Ctrl] = R1				//

		RETF
//----------------------------------------------------
// A2000
//----------------------------------------------------	
///////////////////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of SACM_A2000_Initial() 
//			or F_SACM_A2000_Initial:
// Note: The following functions are the partial code of original
//			initial subroutine. (H/W setting part) 
//
//	Ex: F_SACM_A2000_Initial:
//			...
//			call F_SP_SACM_A2000_Init_	: S480/S240/MS01 is same
//			...
//			retf
////////////////////////////////////////////////////////////////////////////////
F_SP_SACM_A2000_Init_:	
		R1=C_SystemClock;               // 24MHz, Fcpu=Fosc
        [P_SystemClock]=R1           	//  Frequency 20MHz
        R1 = 0x0030                     // TimerA CKA=Fosc/2 CKB=1 Tout:off
        [P_TimerA_Ctrl] = R1			// Initial Timer A
        R1 = C_A2000_Timer_Setting                   	// 16K
        [P_TimerA_Data] = R1 
        R1 = 0x00A8                     // Set the DAC Ctrl
        [P_DAC_Ctrl] = R1
        R1 = 0xffff
        
        [P_INT_Clear] = R1          	// Clear interrupt occuiped events

        
        .if BODY_TYPE == SPCE061A
        R1 = [P_INT_Mask]		//
        .endif
      //  .if BODY_TYPE == SPCE500A
      //  R1 = [R_InterruptStatus]		//
     //   .endif 
                
        R1 |= C_FIQ_TMA					// Enable Timer A FIQ

     //   [R_InterruptStatus] = R1		//
        [P_INT_Ctrl] = R1				//

		RETF



//----------------------------------------------------
// A3200 1ch
//----------------------------------------------------	
.public F_SP_SACM_A3200_Init_
.public F_SACM_A3200_SetTimerSrc			
.public F_SACM_A3200_SetIntSrc
.public F_SACM_A3200_SendDecodedData
//////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of 
//			 SACM_A3200_Initial() or F_SACM_A3200_Initial:
//           Single Channel A3200      
//////////////////////////////////////////////////////////////////
F_SP_SACM_A3200_Init_:	.proc 
//	R1 = 0x0020;		// 20MHz 	
//	R1 = 0x0000;		// 24MHz
//	R1 = 0x0040;		// 32MHz						
//	R1 = 0x0060;		// 40MHz
//	R1 = 0x0080;		// 49MHz
	R1 = C_SystemClock
	[P_SystemClock] = R1;
	
	R1 = 0x00A4; 			// Latch DAR1 data to DAC1 by TimerA
	[P_DAC_Ctrl] = R1;  	// Latch DAR2 data to DAC2 by TimerA	
	
	RETF;
.endp 
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_SetTimerSrc
//-- Parameter: R1 : TimerData
//-- Return: NONE
//-- Description: This function called by A3200 library to set timer A                 
//--------------------------------------------------------------------
F_SACM_A3200_SetTimerSrc: .proc
	push R2 to [sp];
	R2 = 0x0030;
	[P_TimerA_Ctrl] = R2;	// select Fosc/2 as Timer A clock source 
	[P_TimerA_Data] = R1;
	pop R2 from [sp];
	retf;
.endp	
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_SetIntSrc
//-- Parameter: NONE
//-- Return: NONE
//-- Description: This function called by A3200 library to set  
//                interrupt 
//--------------------------------------------------------------------
F_SACM_A3200_SetIntSrc: .proc 
	push R1 to [SP];
    .if BODY_TYPE == SPCE061A
     R1 = [P_INT_Mask]		//
    .endif
   // .if BODY_TYPE == SPCE500A
   //  R1 = [R_InterruptStatus]		//
   // .endif 

	R1 |= C_IRQ1_TMA;
//	[R_InterruptStatus] = R1;
	[P_INT_Ctrl] = R1;
	pop R1 from [SP];
	RETF;
.endp
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_SendDecodedData
//-- Parameter: R1 : decoded sample
//-- Return: NONE
//-- Description: This function called by A3200 library to send  
//                decoded data to DACs
//--------------------------------------------------------------------
F_SACM_A3200_SendDecodedData: .proc
	[P_DAC1] = R1;
	[P_DAC2] = R1;
	RETF;
.endp 		

		

//----------------------------------------------------
// A3200 2ch
//----------------------------------------------------	
.public F_SP_SACM_2Ch_A3200_Init_
.public F_SACM_A3200_Ch1_SetTimerSrc			
.public F_SACM_A3200_Ch1_SetIntSrc
.public F_SACM_A3200_Ch1_SendDecodedData
.public F_SACM_A3200_Ch2_SetTimerSrc			
.public F_SACM_A3200_Ch2_SetIntSrc
.public F_SACM_A3200_Ch2_SendDecodedData
//////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of 
//			 SACM_2Ch_A3200_Initial() or F_SACM_2Ch_A3200_Initial:
//           2 Channel A3200  
//////////////////////////////////////////////////////////////////
F_SP_SACM_2Ch_A3200_Init_:	
//		R1 = 0x0020;		// 20MHz 	
//		R1 = 0x0000;		// 24MHz
//		R1 = 0x0040;		// 32MHz						
//		R1 = 0x0060;		// 40MHz
//		R1 = 0x0080;		// 49MHz
		R1 = C_SystemClock

        [P_SystemClock] = R1;           	
         
        R1 = 0x00C4;                     // Latch DAR1 data to DAC1 by TimerA
        [P_DAC_Ctrl] = R1;               // Latch DAR2 data to DAC2 by TimerB
        
        R1 = 0xffff;
        [P_INT_Clear] = R1;
                 
        RETF
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch1_SetTimerSrc
//-- Parameter: R1 : TimerData
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to set timer A 
//                for channel 1
//--------------------------------------------------------------------

F_SACM_A3200_Ch1_SetTimerSrc: .proc
	push R2 to [sp];
	R2 = 0x0030;
	[P_TimerA_Ctrl] = R2;	// select Fosc/2 as Timer A clock source 
	[P_TimerA_Data] = R1;
	pop R2 from [sp];
	retf;
.endp	
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch1_SetIntSrc
//-- Parameter: NONE
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to set  
//                interrupt for channel 1
//--------------------------------------------------------------------
F_SACM_A3200_Ch1_SetIntSrc: .proc 
	push R1 to [SP];
    .if BODY_TYPE == SPCE061A
     R1 = [P_INT_Mask]		//
    .endif
   // .if BODY_TYPE == SPCE500A
   //  R1 = [R_InterruptStatus]		//
   // .endif 

	R1 |= C_IRQ1_TMA;
//	[R_InterruptStatus] = R1;
	[P_INT_Ctrl] = R1;
	pop R1 from [SP];
	RETF;
.endp
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch1_SendDecodedData
//-- Parameter: R1 : decoded sample
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to send  
//                decoded data to DAC1
//--------------------------------------------------------------------
.external _Ch1_Stop
F_SACM_A3200_Ch1_SendDecodedData: .proc
	[P_DAC1] = R1;
	RETF;
.endp 		

//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch2_SetTimerSrc
//-- Parameter: R1 : TimerData
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to set  
//                timer B for channel 2
//--------------------------------------------------------------------

F_SACM_A3200_Ch2_SetTimerSrc: .proc
	push R2 to [sp];
	R2 = 0x0000;
	[P_TimerB_Ctrl] = R2;	// select Fosc/2 as Timer B clock source 
	[P_TimerB_Data] = R1;
	pop R2 from [sp];
	retf;
.endp	
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch2_SetIntSrc
//-- Parameter: NONE
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to set  
//                interrupt for channel 2
//--------------------------------------------------------------------
F_SACM_A3200_Ch2_SetIntSrc: .proc 
	push R1 to [SP];
    .if BODY_TYPE == SPCE061A
     R1 = [P_INT_Mask]		//
    .endif
 //   .if BODY_TYPE == SPCE500A
 //    R1 = [R_InterruptStatus]		//
 //   .endif 

	R1 |= C_IRQ2_TMB;
//	[R_InterruptStatus] = R1;
	[P_INT_Ctrl] = R1;
	pop R1 from [SP];
	RETF;
.endp
//--------------------------------------------------------------------
//-- Function: F_SACM_A3200_Ch2_SendDecodedData
//-- Parameter: R1 : decoded sample
//-- Return: NONE
//-- Description: This function called by 2Ch A3200 library to send  
//                decoded data to DAC2
//--------------------------------------------------------------------

F_SACM_A3200_Ch2_SendDecodedData: .proc
	[P_DAC2] = R1;
	RETF;
.endp 		



//----------------------------------------------------
// S530
//----------------------------------------------------	
//////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of SACM_S530_Initial() 
//			or F_SACM_S530_Initial:
//////////////////////////////////////////////////////////////////
// Sampling rate   |   data rate   |   TimerA_Data   | CPU(24MHz) % 
// -----------------------------------------------------------------  
//     8K Hz       |   5.3  Kbps   |     0xfa00      |    50 %
//     9K Hz       |   5.96 Kbps   |     0xfaaa      |    56 %  
//    10K Hz       |   6.63 Kbps   |     0xfb33      |    63 %
//    11K Hz       |   7.29 Kbps   |     0xfba2      |    69 %  
//    12K Hz       |   7.95 Kbps   |     0xfc00      |    75 %      

F_SP_SACM_S530_Init_:
        R1 = C_SystemClock;				// system clock 49MHz Fosc,CPU clock 49MHz
        //R1 = 0x0080;					// system clock 24MHz Fosc,CPU clock 24MHz
        [P_SystemClock]=R1          	// Initial System Clock
        R1 = 0x0030                     // TimerA CKA=Fosc/2 CKB=1 Tout:off
        [P_TimerA_Ctrl]=R1				// Initial Timer A
        //R1 = 0xfa00                  	//  8KHz, Using  8KHz to play  8KHz audio data. 
        //R1 = 0xfaaa                  	//  9KHz, Using  9KHz to play  9KHz audio data. 
        //R1 = 0xfb33                  	// 10KHz, Using 10KHz to play 10KHz audio data. 
        //R1 = 0xfba2 					// 11KHz, Using 11KHz to play 11KHz audio data. 
        R1 = C_S530_Timer_Setting      	// 12KHz, Using 12KHz to play 12KHz audio data.
        [P_TimerA_Data]=R1
        R1 = 0x00A8				// 
        [P_DAC_Ctrl] = R1				//
        
        R1 = 0xffff
        [P_INT_Clear] = R1          	// Clear interrupt occuiped events
        
        .if BODY_TYPE == SPCE061A
        R1 = [P_INT_Mask]		//
        .endif
   //     .if BODY_TYPE == SPCE500A
  //      R1 = [R_InterruptStatus]		//
  //      .endif 
        
        R1 |= C_FIQ_TMA					// Enable Timer A FIQ
  
 //       [R_InterruptStatus] = R1		//
        [P_INT_Ctrl] = R1				//	
        INT IRQ,FIQ	      
        RETF
//----------------------------------------------------
// S480
//----------------------------------------------------
//////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of SACM_S480_Initial() 
//			or F_SACM_S480_Initial:
//////////////////////////////////////////////////////////////////
F_SP_SACM_S480_Init_:
        R1 = C_SystemClock					// 24MHz Fosc
        [P_SystemClock]=R1          	// Initial System Clock
        R1=0x0030                       // TimerA CKA=Fosc/2 CKB=1 Tout:off
        [P_TimerA_Ctrl]=R1				// Initial Timer A
        R1 = C_S480_Timer_Setting      	// 24K
        //R1 = 0xfd00                  	// 16K
        //R1 = 0xfc00                  	// 12KHz
        [P_TimerA_Data]=R1
        R1 = 0x00A8						// 
        [P_DAC_Ctrl] = R1				//
        
        R1 = 0xffff
        [P_INT_Clear] = R1          	// Clear interrupt occuiped events
        
        .if BODY_TYPE == SPCE061A
        R1 = [P_INT_Mask]		//
        .endif
    //    .if BODY_TYPE == SPCE500A
   //     R1 = [R_InterruptStatus]		//
   //     .endif 
        
        R1 |= C_FIQ_TMA					// Enable Timer A FIQ
   //     [R_InterruptStatus] = R1		//
        [P_INT_Ctrl] = R1				//
        RETF

//----------------------------------------------------
// S240
//----------------------------------------------------
//////////////////////////////////////////////////////////////////
// Function: The partial code of hardware setting of SACM_S240_Initial() 
//			or F_SACM_S240_Initial:
//////////////////////////////////////////////////////////////////
F_SP_SACM_S240_Init_:	
		R1 = C_SystemClock;	
		[P_SystemClock]=R1
		R1 = 0x00A8;					// 
		[P_DAC_Ctrl]= R1
		R1 = 0x0030;               	// TimerA CKA=Fosc/2 CKB=1 Tout:off
        [P_TimerA_Ctrl] = R1;
		R1 = C_S240_Timer_Setting;                    // 24K
    	[P_TimerA_Data] = R1;		
        R1 = 0xffff
        [P_INT_Clear] = R1          	// Clear interrupt occuiped events

⌨️ 快捷键说明

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