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

📄 access4096.asm

📁 本人下载的电力系统相关资料,具有极其重要的参考价值
💻 ASM
📖 第 1 页 / 共 2 页
字号:
		r4=[P_SDA_Buffer];
		r4&=C_SDA_PIN^0xFFFF;
		[P_SDA_Buffer]=R4;			//Set SDA to low;
		call F_BringAClock;	
L_Send9BitAddr_Next:
		r2=r2 lsl 1;
		r3-=1;
		jnz L_Send9BitAddr;
	
		r3=0x10;
L_Send16BitAddr:
		r4=r1&0x8000;
		JZ L_16BitAddr_Is_Zero;
		r4=[P_SDA_Buffer];
		r4|=C_SDA_PIN;
		[P_SDA_Buffer]=R4;			//Set SDA to high;
		call F_BringAClock;		
		jmp L_Send16BitAddr_Next;
L_16BitAddr_Is_Zero:
		r4=[P_SDA_Buffer];
		r4&=C_SDA_PIN^0xFFFF;
		[P_SDA_Buffer]=R4;			//Set SDA to low;
		call F_BringAClock;	
L_Send16BitAddr_Next:
		r1=r1 lsl 1;
		r3-=1;
		jnz L_Send16BitAddr;	
		pop r1,r4 from [sp];
		retf;
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        : r3
// Output       : 
// Destroy 		: 
// Used 		: 
//==========================================================================================
F_WriteDataTO4096:
		push r1,r2 to [sp];
		r1=0x8;
L_Send8BitData:
		r2=r3&0x0080;
		JZ L_8BitData_Is_Zero;
		r2=[P_SDA_Buffer];
		r2|=C_SDA_PIN;
		[P_SDA_Buffer]=r2;			//Set SDA to high;
		call F_BringAClock;	
		jmp L_Send8BitData_Next;
L_8BitData_Is_Zero:
		r2=[P_SDA_Buffer];
		r2&=C_SDA_PIN^0xFFFF;
		[P_SDA_Buffer]=r2;			//Set SDA to low;
		call F_BringAClock;	
L_Send8BitData_Next:
		r3=r3 lsl 1;
		r1-=1;
		jnz L_Send8BitData;
		pop r1,r2 from [sp];
		retf	
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       : 
// Destroy 		: 
// Used 		: 
//==========================================================================================
F_BringAEndClock:
		push r1 to [sp];
		//set SCK to low
		r1=[P_SCK_Buffer];
		r1&=C_SCK_PIN^0xFFFF;
		[P_SCK_Buffer]=r1;
		call F_BringAClockDelay;
		//set SCK to high
		r1=[P_SCK_Buffer];
		r1|=C_SCK_PIN;
		[P_SCK_Buffer]=r1;
		call F_BringAClockDelay;
		pop r1 from [sp];
		retf;
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       : 
// Destroy 		: 
// Used 		: 
//==========================================================================================
F_IO_EndReadOrWrite:
		push r1 to [sp];
		//set SCK Pin to high
		r1=[P_SCK_Buffer];
		r1|=C_SCK_PIN;
		[P_SCK_Buffer]=r1;
		//set SDA Pin to low
		r1=[P_SDA_Buffer];
		r1&=C_SDA_PIN^0xFFFF;
		[P_SDA_Buffer]=r1;
		call F_BringAClockDelay;
		//set SDA Pin to high
		r1=[P_SDA_Buffer];
		r1|=C_SDA_PIN;
		[P_SDA_Buffer]=r1;
		pop r1 from [sp];
		retf;
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       : 
// Destroy 		: 
// Used 		: 
//==========================================================================================	
F_IO_Set_SDA_LowOutPut:
		push r1 to [sp];
		call F_BringAClockDelay;
		//	set SDA output with low
		r1=[P_SDA_Attrib];
		r1|=C_SDA_PIN; 
		[P_SDA_Attrib]=r1;
		
		r1=[P_SDA_Dir];
		r1|=C_SDA_PIN; 
		[P_SDA_Dir]=r1;
		
		r1=[P_SDA_Buffer];
		r1&=C_SDA_PIN^0xFFFF;
		[P_SDA_Buffer]=r1;
		pop r1 from [sp];
		retf;
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
//===========================================================================================
// Description  :  SPR4096 Mass Earse
// Syntax       :  
// Input        :  
// Output       :  
// Destroy 		:
// Used 		:  
//==========================================================================================
.PUBLIC  _SPR4096_IO_MassErase;
.PUBLIC  F_SPR4096_IO_MassErase;
F_SPR4096_IO_MassErase:
_SPR4096_IO_MassErase:
		push r1,r2 to [sp];
		r1=0x0000;
		r2=0x00C0;
		call F_IO_WriteAddrTO4096;
		call F_WriteDataTO4096;
		call F_IO_EndReadOrWrite;//F_EndWrite;
		call F_Delay_MassErase_Time;
		pop r1,r2 from [sp];
		retf;	
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       :  
// Destroy 		:
// Used 		:  
//==========================================================================================
.public _SPR4096_IO_SectorErase;
_SPR4096_IO_SectorErase: .PROC
        PUSH bp,bp TO [SP];
        bp = sp + 1;
        r1 = [bp+3];			//get page number that will be erased
        r1=r1&0x00ff;			//	
		call F_SPR4096_IO_SectorErase;
        POP BP,BP FROM [SP];
        retf;
.ENDP;
//===========================================================================================
// Function Name:  
// Description  :  
// Syntax       :  
// Input        :  r1:save page number that will be erased .the range of r1 is from 0 to 256
// Output       :  None
// Destroy 		:  none
// Used 		:  r1,r2
//==========================================================================================
.public F_SPR4096_IO_SectorErase;
F_SPR4096_IO_SectorErase:.PROC
		push r1,r2 to [sp];
		r2=r1;					//r1 save page number that will be erased
		r1=r1 lsl 4;
		r1=r1 lsl 4;
		r1=r1 lsl 3;			//r1 save low 16bits Addr 
		r2=r2 lsr 4;
		r2=r2 lsr 1;			//r2 save high 9bits Addr;
		r2|=0x0080;
		call F_IO_WriteAddrTO4096;
		call F_WriteDataTO4096;
		call F_IO_EndReadOrWrite;//F_EndWrite;
        call    F_Delay_SectorErase_Time
		pop r1,r2 from [sp];
		retf
.ENDP;
		       
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       :  
// Destroy 		:
// Used 		:  
//==========================================================================================
F_Delay_Program_Time:
		push r1 to [sp];
		r1=C_Program_Time;				//6
?L_Wait_Program_Time_Over:							//52cycle,1us @ 49Mhz       
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4
		nop;							//4		
		r1-=1;							//3
		jnz ?L_Wait_Program_Time_Over;	//5
		pop r1 from [sp];
		retf;							//12
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       :  
// Destroy 		:
// Used 		:  
//==========================================================================================
.public F_Delay_MassErase_Time;
F_Delay_MassErase_Time:

		r2=C_MassErase_Time;		
?L_Wait_MassErase_Time_Over:
		r3=0x0001;
		[P_Watchdog_Clear]=r3;							       
		call	F_Delay_Program_Time;
		r2-=1;						
		jnz ?L_Wait_MassErase_Time_Over;		
		retf;						
//===========================================================================================
// Function Name: 
// Description  :  
// Syntax       :  
// Input        :  
// Output       :  
// Destroy 		:
// Used 		:  
//==========================================================================================
.public F_Delay_SectorErase_Time;
F_Delay_SectorErase_Time:
		r2=C_SectorErase_Time;				//6	
?L_Wait_SectorErase_Time_Over:							       
		call	F_Delay_Program_Time;
		r2-=1;								//3					
		jnz ?L_Wait_SectorErase_Time_Over;	//5	
		retf;	
.public _ClearWatchDog;
_ClearWatchDog:
		push r1 to [sp];
		r1=0x0001;
		[P_Watchdog_Clear]=r1;
		pop r1 from [sp];
		retf;

⌨️ 快捷键说明

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