
;------------------------------------------------------------------------------
;  CHIP: SN8P27184, OTP Only.
;  Revision History:
;  V0.1 09/17/2013  First issue - Modified from 2929
;  V0.2 09/26/2013  1. Modify USER_ROM_SIZE:0x0FFB
;		    2. Add Code Option 0x0FFC Definition	
;		    3. Modify FADCKS1 EQU ADR.5 / add FADCKS2 EQU ADR.6
;  V0.3 10/03/2013  1. Modify Low Power Mode:2bits
;  V0.4 10/27/2013  1. Add FTEST, FSDMEN bit in FRM Register
;		    2. Add FRD Register @ 090H
;  V0.5 10/30/2013  1. Add FRD[5:2] in FRD Register @ 090H
;  V0.6	11/20/2013  1. Modify Code Option:Low Power Mode	
;  V0.6	03/13/2019  1. Modify file inc name	
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------

.Assembly	INC_VER		1
.Assembly       RedWrt_FORMAT   1
.Assembly	ASM_FORMAT	1
.Assembly	RAM_Size	100h

.Assembly	INSTRUMENT	SN8P27184
.Assembly	BIT_FILE	SN8P27184

.Assembly	OTP_BODY_SIZE	0x1000
.Assembly	USER_ROM_SIZE	0x0FFB

.Assembly	COMMAND		Enable_ORG4_7		 	; Limit org 4~7, unavailible for user
.Assembly	PGM_TYPE	6				; 2's Program Type			
.Assembly	MASK_TEST_CODE	0x0000, 0x000, 0x0000, 0x0000
.Assembly	Port_Pins	7, 4, 0, 0, 3, 0, 0
;.Assembly	LCD_Size	20, 4
.Assembly	CHIP_ID		0x6550

; Code Option 0x0FFF
.Assembly	OPTION			0		Noise_Filter	Disable Enable
.Assembly	OPTION			1		Security	Enable	Disable
.Assembly	OPTION			2		High_Clk_DIV	Fhosc/4 Fhosc/8	Fhosc/16 Fhosc/32 
.Assembly	OPTION			4		High_Clk	IHRC_4M x x x Ext_RC 32K_X'tal 12M_X'tal 4M_X'tal
.Assembly	OPTION			7		Watch_Dog	x x x x x Enable x x x x Disable x x x x Always_On 
.Assembly	OPTION			11 : 13		Fix_Low
.Assembly	OPTION			14 		Low_Power	Disable 40ns 80ns 120ns


; Code Option 0x0FFE
.Assembly	OPTION			16		Fix_Low
.Assembly	OPTION			17		Fix_High
.Assembly	OPTION			18		Fix_Low
.Assembly	OPTION			19		Fix_High
.Assembly	OPTION			20		Fix_High
.Assembly	OPTION			21		Fix_Low
.Assembly	OPTION			22		Fix_High
.Assembly	OPTION			23		Fix_Low
.Assembly	OPTION			24		Fix_Low
.Assembly	OPTION			25		Fix_High
.Assembly	OPTION			26		Fix_Low
.Assembly	OPTION			27 : 31		Fix_High

; Code Option 0x0FFD
.Assembly	OPTION			32 : 40		Fix_High ;(IHRC_CAL_Data)
.Assembly	OPTION			41 : 47		Fix_High

;Code Option 0x0FFC
.Assembly	OPTION			48 : 52		Fix_High ;(DVDDR_Trim_Data)
.Assembly	OPTION			53 : 55		Fix_High
.Assembly	OPTION			56 : 59		Fix_High ;(Int.Vref_Trim_Data)
.Assembly	OPTION			60 : 63		Fix_High
;============================================================================
;.Assembly	OPTION			48 : 63		Fix_High
.Assembly	OPTION			2ffh


	L			EQU		80H
	H			EQU		81H
	R			EQU		82H
	Z			EQU		83H
	Y			EQU		84H
	X			EQU		85H
	
	PFLAG			EQU		86H
		FNT0		EQU		PFLAG.7
		FNPD		EQU		PFLAG.6
		FC		EQU		PFLAG.2
		FDC		EQU		PFLAG.1
		FZ		EQU		PFLAG.0
		
	RBANK			EQU		87H
		FRBNKS0		EQU		RBANK.0

	CPM			EQU		8BH
		FCPA		EQU		CPM.7
		FBGREN		EQU		CPM.3
		FBGM		EQU		CPM.2		
		FCPCKS1		EQU		CPM.1
		FCPCKS0		EQU		CPM.0	

	FRM			EQU		8CH
		FFREN		EQU		FRM.7	
		FOSCO		EQU		FRM.6
		FFTEST		EQU		FRM.5
		FFSDMEN		EQU		FRM.3
		FDUTY2		EQU		FRM.2		
		FDUTY1		EQU		FRM.1
		FDUTY0		EQU		FRM.0

	FRCL			EQU		8DH
		FFRC7		EQU		FRCL.7
		FFRC6		EQU		FRCL.6
		FFRC5		EQU		FRCL.5
		FFRC4		EQU		FRCL.4
		FFRC3		EQU		FRCL.3
		FFRC2		EQU		FRCL.2
		FFRC1		EQU		FRCL.1
		FFRC0		EQU		FRCL.0

	FRCM			EQU		8EH
		FFRC15		EQU		FRCM.7
		FFRC14		EQU		FRCM.6
		FFRC13		EQU		FRCM.5
		FFRC12		EQU		FRCM.4
		FFRC11		EQU		FRCM.3
		FFRC10		EQU		FRCM.2
		FFRC9		EQU		FRCM.1
		FFRC8		EQU		FRCM.0

	FRCH			EQU		8FH
		FFRC23		EQU		FRCH.7
		FFRC22		EQU		FRCH.6
		FFRC21		EQU		FRCH.5
		FFRC20		EQU		FRCH.4
		FFRC19		EQU		FRCH.3
		FFRC18		EQU		FRCH.2
		FFRC17		EQU		FRCH.1
		FFRC16		EQU		FRCH.0
	
	FRD			EQU		90H


		FFRD5		EQU		FRD.5
		FFRD4		EQU		FRD.4
		FFRD3		EQU		FRD.3
		FFRD2		EQU		FRD.2
		FFRD1		EQU		FRD.1
		FFRD0		EQU		FRD.0
			
	AVREFM			EQU		0B0H
		FEVHENB		EQU		AVREFM.7				

	ADM			EQU		0B1H
		FCHS0		EQU		ADM.0
		FCHS1		EQU		ADM.1
		FLVBAT		EQU		ADM.2

		FGCHS		EQU		ADM.4
		FEOC		EQU		ADM.5
		FADS		EQU		ADM.6
		FADENB		EQU		ADM.7
		
	ADB			EQU_R		0B2H

	ADR			EQU		0B3H
		FADB0		EQU_R		ADR.0		
		FADB1		EQU_R		ADR.1
		FADB2		EQU_R		ADR.2
		FADB3		EQU_R		ADR.3
		FADCKS0		EQU		ADR.4
		FADCKS1		EQU		ADR.5
		FADCKS2		EQU		ADR.6	

	P0M			EQU		0B8H
		
		FP06M		EQU		P0M.6
		FP05M		EQU		P0M.5
		FP04M		EQU		P0M.4
		FP03M		EQU		P0M.3
		FP02M		EQU		P0M.2
		FP01M		EQU		P0M.1
		FP00M		EQU		P0M.0

	P4CON			EQU		0BEH
		



		
		FP4CON2		EQU		P4CON.2
		FP4CON1		EQU		P4CON.1
		FP4CON0		EQU		P4CON.0

	PEDGE			EQU		0BFH
		



		FP01G1		EQU		PEDGE.3
		FP01G0		EQU		PEDGE.2
		FP00G1		EQU		PEDGE.1
		FP00G0		EQU		PEDGE.0

	P1W			EQU_W		0C0H
		



		FP13W		EQU_W		P1W.3
		FP12W		EQU_W		P1W.2
		FP11W		EQU_W		P1W.1
		FP10W		EQU_W		P1W.0

	P1M			EQU		0C1H
	


		FP13M		EQU		P1M.3
		FP12M		EQU		P1M.2
		FP11M		EQU		P1M.1
		FP10M		EQU		P1M.0

	P4M			EQU		0C4H
	
	


		FP42M		EQU		P4M.2
		FP41M		EQU		P4M.1
		FP40M		EQU		P4M.0
		
	INTRQ			EQU		0C8H
		FADCIRQ		EQU		INTRQ.7
		FTC1IRQ		EQU		INTRQ.6
		FTC0IRQ		EQU		INTRQ.5
		FT0IRQ		EQU		INTRQ.4
		

		FP01IRQ		EQU		INTRQ.1
		FP00IRQ		EQU		INTRQ.0

	INTEN			EQU		0C9H
		FADCIEN		EQU		INTEN.7
		FTC1IEN		EQU		INTEN.6
		FTC0IEN		EQU		INTEN.5
		FT0IEN		EQU		INTEN.4
		

		FP01IEN		EQU		INTEN.1
		FP00IEN		EQU		INTEN.0

	OSCM			EQU		0CAH




		FCPUM1		EQU		OSCM.4
		FCPUM0		EQU		OSCM.3
		FCLKMD		EQU		OSCM.2
		FSTPHX		EQU		OSCM.1

	WDTR			EQU_W		0CCH
	
	TC0R			EQU_W		0CDH	

	PCL			EQU		0CEH

	PCH			EQU		0CFH

	P0			EQU		0D0H
	
		FP06		EQU		P0.6
		FP05		EQU		P0.5
		FP04		EQU		P0.4
		FP03		EQU		P0.3
		FP02		EQU		P0.2
		FP01		EQU		P0.1
		FP00		EQU		P0.0

	P1			EQU		0D1H
	



		FP13		EQU		P1.3
		FP12		EQU		P1.2
		FP11		EQU		P1.1
		FP10		EQU		P1.0

	P4			EQU		0D4H





		FP42		EQU		P4.2
		FP41		EQU		P4.1
		FP40		EQU		P4.0
	
	T0M			EQU		0D8H
		FT0ENB		EQU		T0M.7
		FT0RATE2	EQU		T0M.6
		FT0RATE1	EQU		T0M.5
		FT0RATE0	EQU		T0M.4
		FTC1X8		EQU		T0M.3
		FTC0X8		EQU		T0M.2
		FTC0GN		EQU		T0M.1
		

	T0C			EQU		0D9H

	TC0M			EQU		0DAH
		FTC0ENB		EQU		TC0M.7
		FTC0RATE2	EQU		TC0M.6
		FTC0RATE1	EQU		TC0M.5
		FTC0RATE0	EQU		TC0M.4
		FTC0CKS		EQU		TC0M.3
		FALOAD0		EQU		TC0M.2
		FTC0OUT		EQU		TC0M.1
		FPWM0OUT	EQU		TC0M.0

	TC0C			EQU		0DBH

	TC1M			EQU		0DCH
		FTC1ENB		EQU		TC1M.7
		FTC1RATE2	EQU		TC1M.6
		FTC1RATE1	EQU		TC1M.5
		FTC1RATE0	EQU		TC1M.4
		FTC1CKS		EQU		TC1M.3
		FALOAD1		EQU		TC1M.2
		FTC1OUT		EQU		TC1M.1
		FPWM1OUT	EQU		TC1M.0

	TC1C			EQU		0DDH

	TC1R			EQU		0DEH

	STKP			EQU		0DFH
		FGIE		EQU		STKP.7
	

	
	
		FSTKPB2		EQU		STKP.2
		FSTKPB1		EQU		STKP.1
		FSTKPB0		EQU		STKP.0

	P0UR			EQU_W		0E0H
		
		FP06R		EQU_W		P0UR.6
		FP05R		EQU_W		P0UR.5
		FP04R		EQU_W		P0UR.4
		FP03R		EQU_W		P0UR.3
		FP02R		EQU_W		P0UR.2
		FP01R		EQU_W		P0UR.1
		FP00R		EQU_W		P0UR.0

	P1UR			EQU_W		0E1H




		FP13R		EQU_W		P1UR.3
		FP12R		EQU_W		P1UR.2
		FP11R		EQU_W		P1UR.1
		FP10R		EQU_W		P1UR.0

	P4UR			EQU_W		0E4H




		
		FP42R		EQU_W		P4UR.2
		FP41R		EQU_W		P4UR.1
		FP40R		EQU_W		P4UR.0
	
	@HL			EQU		0E6H

	@YZ			EQU		0E7H	
	
	STK7L			EQU		0F0h
	STK7H			EQU		0F1h	
	STK6L			EQU		0F2h
	STK6H			EQU		0F3h
	STK5L			EQU		0F4h
	STK5H			EQU		0F5h	
	STK4L			EQU		0F6h
	STK4H			EQU		0F7h	
	STK3L			EQU		0F8h
	STK3H			EQU		0F9h
	STK2L			EQU		0FAh
	STK2H			EQU		0FBh	
	STK1L			EQU		0FCh
	STK1H			EQU		0FDh	
	STK0L			EQU		0FEh
	STK0H			EQU		0FFh
	
; -----------------------------------------------------
; Clear watchdog macro for compatibility in S8KD-2 ICE
;  
; Total Cycle: 2 

	@RST_WDT	macro		
 		   MOV  A, #0x5A
		   B0MOV  WDTR, A
	endm

; -----------------------------------------------------
; Sleep Mode control macro for compatibility in S8KD-2 ICE
;  
; Total Cycle: 1

	SleepMode	macro	
		B0BSET	FCPUM0
	endm

; -----------------------------------------------------
; Green Mode control macro for compatibility in S8KD-2 ICE
;  
; Total Cycle: 3

	GreenMode	macro	
		B0BSET	FCPUM1
		NOP
		NOP
	endm
	
; -----------------------------------------------------
; Slow Mode control macro for compatibility in S8KD-2 ICE
;  
; Total Cycle: 2

	SLowMode	macro	
		B0BSET	FCLKMD
		B0BSET	FSTPHX
	endm

; -----------------------------------------------------
;  Slow mode to Normal Mode control macro for compatibility in S8KD-2 ICE
;  
; Total Cycle: 5

	Slow2Normal	macro	
		B0BCLR	FSTPHX
		NOP
		NOP
		NOP
		B0BCLR	FCLKMD
	endm

; -----------------------------------------------------	
.TEXT
{
	//{{SONIX_OPTION_RULE
        
	ENDP
	//}}SONIX_OPTION_RULE
}