cs_pin		bit	P1.0
clk_pin		bit	P1.1
sdi_pin		bit	P1.2

temp		equ	20h

		org	0000h
;===============================================

vfd_init:	
		setb	cs_pin			
		call	delay200ms		

		;Set number of Grid output used
		clr	cs_pin			
		call	delay_tcsh		
		mov	temp, #11100000B	
		call	data_shout		
		mov	temp, #15		
		call	data_shout		
		call	delay_tcsh		
		nop
		setb	cs_pin			
		call	delay_tcsh		

		;Set dim level
		clr	cs_pin			
		call	delay_tcsh		
		mov	temp, #11100100B	
		call	data_shout		
		mov	temp, #128		
		call	data_shout		
		call	delay_tcsh		
		nop
		setb	cs_pin			
		call	delay_tcsh		

		;Display ON
		clr	cs_pin			
		call	delay_tcsh		
		mov	temp, #11101000B	
		call	data_shout		
		mov	temp, #0		
		call	data_shout		
		call	delay_tcsh		
		nop
		setb	cs_pin			
		call	delay_tcsh		

		;Set position
		clr	cs_pin			
		call	delay_tcsh		
		mov	temp, #20h	; 
		call	data_shout		
		
		mov	temp, #'T'		
		call	data_shout		
		call	delay_tcsh		
		nop
		
		mov	temp, #'E'		
		call	data_shout		
		call	delay_tcsh		
		nop
		
		mov	temp, #'S'		
		call	data_shout		
		call	delay_tcsh		
		nop
		
		mov	temp, #'T'		
		call	data_shout		
		call	delay_tcsh		
		nop
		
		setb	cs_pin			
		call	delay_tcsh		

		;Display ON
		clr	cs_pin			
		call	delay_tcsh		
		mov	temp, #11101000B	
		call	data_shout		
		mov	temp, #0		
		call	data_shout		
		call	delay_tcsh		
		nop
		setb	cs_pin			
		call	delay_tcsh		
		

		orl	PCON, #001h		
		jmp	$			

;===============================================
data_shout:	
		mov	A, temp			
		mov	R6, #008h		
shloop:		nop
		clr	clk_pin 		
		rrc	A			
		mov	sdi_pin, C		
		nop
		setb	clk_pin			
		djnz	R6, shloop		
		ret				
		
;===============================================
delay_tcsh:	nop				
		ret
		
;===============================================
delay200ms:	mov 	030h, #082h		
		mov	031h, #0ABh
next:		djnz	031h, $
		djnz	030h, next
		ret

		end
		
;MCU: STC89C52RC 4.000 MHz X-tal
;Compiler: MCU 8051 IDE 1.4.9
