Discussion in "Project Help" started by    richard1976    Jun 24, 2017.
Sat Jun 24 2017, 06:01 PM
#1
hi i have written this programme and can send data to the object and receive data however when i try to continuously transmit and receive data from device it dos not want to know it works in Isis simulation but not in real pic any help please.
here is my complete code im in pic16f874a asm.
these are the bits that are not working.
test_coins

		MOVLW   b'00000000'
     	MOVWF   RCSTA  

 		MOVLW   b'10010000'
     	MOVWF   RCSTA   
		
		
		
	
		movlw	0x0E
		movwf	datacount
		movlw	0x30
		movwf	FSR

		movlw	0x00
		call	XMIT_RS232
		movlw	0x00
		call	XMIT_RS232
		movlw	0x01
		call	XMIT_RS232
		movlw	0xE5
		call	XMIT_RS232
		movlw	0x1A
		call	XMIT_RS232
	
		goto	rs232_1

rs232_1
			btfss   PIR1,	RCIF 	      ; check for received data
     		goto    rs232_1
		 	movf    RCREG,W
			movwf	INDF
			incf	FSR
			decfsz	datacount
			goto	rs232_1
			goto	senddata_count

senddata_count
			movf	data12,w
			movwf	BIN
			movlw	0x8B
			movwf	address
			call	setaddress1
			call	BIN2BCD
			movf	tens,w
			call	senddata1
			movlw	0x8C
			movwf	address
			call	setaddress1
			movf	ones,w
			call	senddata1
			goto	senddata_coin

senddata_coin
			movlw	0xC5
			movwf	address
			call	setaddress1
			movf	data13,w
			addlw	0x30
			call	senddata1
			goto	senddata_route
			
senddata_route
			movlw	0xCD
			movwf	address
			call	setaddress1
			movf	data14,w
			addlw	0x30
			call	senddata1
			call	Delay_0.2
			call	Delay_0.2
			call	Delay_0.2
			call	Delay_0.2
			goto	test_coins


BIN2BCD



;in: BIN
;out huns. tens, ones

;uses ADD-3 algoerthm

	movlw 8
	movwf countt
	clrf huns
	clrf tens
	clrf ones

BCDADD3

	movlw 5
	subwf huns, 0
	btfsc STATUS, C
	CALL ADD3HUNS
	movlw 5
	subwf tens, 0
	btfsc STATUS, C
	CALL ADD3TENS
	movlw 5
	subwf ones, 0
	btfsc STATUS, C
	CALL ADD3ONES
	decf countt, 1
	bcf STATUS, C
	rlf BIN, 1
	rlf ones, 1
	btfsc ones,4 ; 
	CALL CARRYONES
	rlf tens, 1
	btfsc tens,4 ; 
	CALL CARRYTENS
	rlf huns,1
	bcf STATUS, C
	movf countt, 0
	btfss STATUS, Z
	GOTO BCDADD3
	movf huns, 0 ; add ASCII Offset
	addlw h'30'
	movwf huns
	movf tens, 0 ; add ASCII Offset
	addlw h'30'
	movwf tens
	movf ones, 0 ; add ASCII Offset
	addlw h'30'
	movwf ones
	RETURN
ADD3HUNS
	movlw 3
	addwf huns,1
	RETURN
ADD3TENS
	movlw 3
	addwf tens,1
	RETURN
ADD3ONES
	movlw 3
	addwf ones,1
	RETURN
CARRYONES
	bcf ones, 4
	bsf STATUS, C
	RETURN
CARRYTENS
	bcf tens, 4
	bsf STATUS, C
	RETURN
and this.
coin_drop
	MOVLW   b'00000000'
     	MOVWF   RCSTA  

 		MOVLW   b'10010000'
     	MOVWF   RCSTA  
		movlw	0x0B
		movwf	datacount
		movlw	0x30
		movwf	FSR
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0xE2
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x1D
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
	
		goto	rs232_2

rs232_2
			btfss   PIR1,	RCIF 	      ; check for received data
     		goto    rs232_2
		 	movf    RCREG,W
			movwf	INDF
			incf	FSR
			decfsz	datacount
			goto	rs232_2
			goto	display_coin_drop
			
display_coin_drop
			movlw	0xC7
			movwf	address
			call	setaddress1
			movf	data1,w
			movwf	BIN
			call	BIN2BCD
			movf	ones,w
			call	senddata1
			movf	data1,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	call_senddata
			goto	prog_finished
call_senddata
			
		
			call	Delay_0.2
			call	Delay_0.2
			goto	coin_drop


and this is the complete programme:
;**********Pic header file**********
        #include <P16F874A.inc>
#define		_0 0x30
#define		_1 0x31
#define		_2 0x32
#define		_3 0x33
#define		_4 0x34
#define		_5 0x35
#define		_6 0x36
#define		_7 0x37
#define		_8 0x38
#define		_9 0x39
#define		_a 0x41
#define		_b 0x42
#define		_c 0x43
#define		_d 0x44
#define		_e 0x45
#define		_f 0x46
#define		_g 0x47
#define		_h 0x48
#define		_i 0x49		; for display characters
#define		_j 0x4a
#define		_k 0x4b
#define		_l 0x4c
#define		_m 0x4d
#define		_n 0x4e
#define		_o 0x4f
#define		_p 0x50
#define		_q 0x51
#define		_r 0x52
#define		_s 0x53
#define		_t 0x54
#define		_u 0x55
#define		_v 0x56
#define		_w 0x57
#define		_x 0x58
#define		_y 0x59
#define		_z 0x5a
#define		_sp	0x20
#define		_equals 0x3d
#define		_slash	0x2f        
#define		_#	0x23
#define		_star 0x2a
#define		_.		0x2e		
;**********File Registers (Bank 0)**********
count1		equ		0x20
count2		equ		0x21
address		equ		0x22
count		equ		0x23
count3		equ		0x24
count4		equ		0x25
count5		equ		0x26
second		equ		0x27
first		equ		0x28
datacount	equ		0x29
tx			equ		0x2A
datacheck	equ		0x2B
datacheck1	equ		0x2C
count6		equ		0x2D
count7		equ		0x2E
count8		equ		0x2F
data1       equ		0x30
data2		equ		0x31
data3		equ		0x32
data4		equ		0x33
data5		equ		0x34
data6		equ		0x35
data7		equ		0x36
data8		equ		0x37
data9		equ		0x38
data10		equ		0x39
data11		equ		0x3a
data12		equ		0x3b
data13		equ		0x3c
data14		equ		0x3d
data15		equ		0x3e
data16		equ		0x3f
data17		equ		0x40
data18		equ		0x41
data19		equ		0x42
data20		equ		0x43
data21		equ		0x44
data22		equ		0x45
datacheck2	equ		0x46
countt		equ		0x47
huns		equ		0x48
tens		equ		0x49
ones		equ		0x4A
BIN			equ		0x4B
erase_count		equ		0x4C
erase2		equ		0x4D
count9		equ		0x4E
count10		equ		0x4F
d1			equ		0x50
d2			equ		0x51
d3			equ		0x52
id_count	equ		0x53
channel_No	equ		0x54
channel_id_1	equ	0x55
channel_id_2	equ	0x56
channel_id_3	equ	0x57
channel_id_4	equ	0x58
channel_id_5	equ	0x59
channel_id_6	equ	0x5A
crc			equ		0x5B
route_channel	equ	0x5C
route_number	equ	0x5D
crc_added		equ	0x5E
;**********Reset Vectors **********
 
        org    0x00    ;16F877A reset vector
        goto  INIT
       	
;**********Subroutines**********
; Delay = 1 seconds
; Clock frequency = 20 MHz

; Actual delay = 1 seconds = 5000000 cycles
; Error = 0 %

	

_1_sec_delay
			;4999993 cycles
	movlw	0x2C
	movwf	d1
	movlw	0xE7
	movwf	d2
	movlw	0x0B
	movwf	d3
_1_sec_delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	_1_sec_delay_0

			;3 cycles
	goto	$+1
	nop

			;4 cycles (including call)
	return
;100ms delay

_100ms_delay
		movlw	0x00		;1F
		movwf	count1
		movlw	0x08
		movwf	count2
delay1_0 
		decfsz	count1, f		; 100ms delay
		goto	$+2
		decfsz	count2, f
		goto	delay1_0
		goto	$+1
		return
switch_delay
		movlw	0xFF		;1F
		movwf	count9
		movlw	0xFF
		movwf	count10
delay1_1
		decfsz	count9, f		; 100ms delay
		goto	$+2
		decfsz	count10, f
		goto	delay1_1
		goto	$+1
		return
_3_second_delay
	movlw	0x88
	movwf	count3
	movlw	0xB3
	movwf	count4
	movlw	0x21
	movwf	count5
_1_second_delay_0
	decfsz	count3, f
	goto	$+2
	decfsz	count4, f
	goto	$+2
	decfsz	count5, f
	goto	_1_second_delay_0

			;6 cycles
	goto	$+1
	goto	$+1
	goto	$+1
	return

Delay_0.2
			;999990 cycles
	movlw	0x07
	movwf	count6
	movlw	0x2F
	movwf	count7
	movlw	0x03
	movwf	count8
Delay_0.2_0
	decfsz	count6, f
	goto	$+2
	decfsz	count7, f
	goto	$+2
	decfsz	count8, f
	goto	Delay_0.2_0

			;6 cycles
	goto	$+1
	goto	$+1
	goto	$+1

			;4 cycles (including call)
	return

_10ms_delay
		movlw	0xFF		;1F
		movwf	count4
		movlw	0x4F
		movwf	count5
delay1
		decfsz	count4, f		; 100ms delay
		goto	$+2
		decfsz	count5, f
		goto	delay1
		goto	$+1
		return
;************ make rb0 to rb7 outputs ********************
INIT
		bsf		STATUS,RP0 		; BANK 1

		MOVLW B'00000111' ;DISABLE COMPARATORS MODULES
		MOVWF CMCON

		movlw b'00000110'
		movwf ADCON1

		movlw b'111000'	    	; make porta outputs
		movwf TRISA	

		movlw b'00000000'		; make portb  outputs
		movwf TRISB	

		movlw b'10000000'		; make portc outputs
		movwf TRISC

		movlw	b'00000000'		; make portd rd0 to rd2 outputs rd3 to rd 6 inputs
		movwf	TRISD

		movlw b'000'	    	; make porte outputs
		movwf TRISE	

		bcf		STATUS,RP0		; bank 0
		clrf	PORTA
		clrf	PORTB
		clrf	PORTC
		clrf	PORTD	
		clrf	PORTE




;USART Serial routines

SER_INIT
            BSF     STATUS, RP0           ;select bank 1
     		MOVLW   d'129'                ;9600 baud @ 20 Mhz Fosc +0.16 err
     		MOVWF   SPBRG
     		MOVLW   b'00100100'           ;brgh = 1
     		MOVWF   TXSTA                 ;enable Async Transmission, set brgh
            BCF     STATUS, RP0           ;select bank 0
     		MOVLW   b'10010000'
     		MOVWF   RCSTA                 ;enable Async Reception

;End of serial routines

;**********Initialise**********
START	 
		nop ; FOR ICD
		call	_1_sec_delay
		movlw 0x0c		; no cursor or blink 
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms_delay
		bcf	  PORTA,1

		movlw 0x38		; 2 line display
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms_delay
		bcf	  PORTA,1
		
		
mainprog
		lcall	initialise
		bcf		PCLATH,3
		bcf		PCLATH,4
		call	_3_second_delay
		lcall	name
		bcf		PCLATH,3
		bcf		PCLATH,4
		call	_3_second_delay
		
start
		
		call	cleardisplay1
		lcall 	connect_coin_mech
		bcf		PCLATH,3
		bcf		PCLATH,4
		lcall	then_press_enter
		bcf		PCLATH,3
		bcf		PCLATH,4
wait
		call	Delay_0.2
		btfsc	PORTA,5
		goto 	wait
		goto	connecting


connecting
		lcall	connecting_now
		bcf		PCLATH,3
		bcf		PCLATH,4
		goto	request_id
		
request_id
		MOVLW   b'10000000'
     	MOVWF   RCSTA  

 		MOVLW   b'10010000'
     	MOVWF   RCSTA   
		

		movlw	0xFF
		movwf	datacheck
		movlw	0xFF
		movwf	datacheck1
		movlw	0x0D
		movwf	datacount
		movlw	0x30
		movwf	FSR
		

requestid
		movlw	0x00
		call	XMIT_RS232
		movlw	0x00
		call	XMIT_RS232
		movlw	0x01
		call	XMIT_RS232
		movlw	0xF4
		call	XMIT_RS232
		movlw	0x0B
		call	XMIT_RS232
		
		goto	rs232


		
		

	
;********* RS232 TX RX ***************
XMIT_RS232  
			bcf		STATUS,RP0
busy
			btfss   PIR1,	TXIF 	      ;xmit buffer empty?
     		goto	busy          ;no, wait
     		movwf   TXREG		      ;now send
            return  





Rcv_RS232   
			decfsz	datacheck
			goto	rs232
			decfsz	datacheck1
			goto	rs232
			goto	not_connected



rs232
			btfss   PIR1,	RCIF 	      ; check for received data
     		goto    Rcv_RS232
		 	movf    RCREG,W
			movwf	INDF
			incf	FSR
			decfsz	datacount
			goto	Rcv_RS232 
			goto	get_data1
			


not_connected
			call	cleardisplay1
			lcall	_not
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	_connected
			bcf		PCLATH,3
			bcf		PCLATH,4
			call	_3_second_delay
			lcall	check_connection
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	then_press_enter
			bcf		PCLATH,3
			bcf		PCLATH,4
			call	_3_second_delay
			goto	wait


	
get_data1
			call	cleardisplay1
			movlw	0x80
			movwf 	address
			call	setaddress
			movf	data10,w
			call	senddata1	
			movf	data11,w
			call	senddata1
			movf	data12,w
			call	senddata1
			movf	data13,w
			call	senddata1
			lcall	_connected
			bcf		PCLATH,3
			bcf		PCLATH,4
			

			call	_3_second_delay
			goto	wait3
wait3	
			call	cleardisplay1	
			lcall	select_option
erase1		bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	erase_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
press_enter
			
			btfsc	PORTA,5
			goto 	press_select
enter_1		btfss	PORTA,5
			goto	enter_1
			goto	erase_channels
press_select
			btfsc	PORTA,4
			goto 	press_enter
select_1	btfss	PORTA,4
			goto	select_1
			goto	prog
prog		lcall	prog_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
programme1
			btfsc	PORTA,5
			goto 	press_select1
enter_2		btfss	PORTA,5
			goto	enter_2
			goto	programme_channels
press_select1
			btfsc	PORTA,4
			goto 	programme1
select_2	btfss	PORTA,4
			goto	select_2
			goto	coin_id
coin_id
			lcall	set_coin_id
			bcf		PCLATH,3
			bcf		PCLATH,4
coin_id1
			btfsc	PORTA,5
			goto	press_select2
enter_3		btfss	PORTA,5
			goto	enter_3
			goto	prog_id
press_select2
			btfsc	PORTA,4
			goto	coin_id1
select_3	btfss	PORTA,4
			goto	select_3
			goto	routing
routing		
			lcall	set_routing
			bcf		PCLATH,3
			bcf		PCLATH,4
routing1
			btfsc	PORTA,5
			goto	press_select3
enter_4		btfss	PORTA,5
			goto	enter_4
			goto	prog_routing
press_select3
			btfsc	PORTA,4
			goto	routing1
select_4	btfss	PORTA,4
			goto	select_4
			goto	test_all_coins
test_all_coins
			lcall	test_coin
			bcf		PCLATH,3
			bcf		PCLATH,4
coin1
			btfsc	PORTA,5
			goto	press_select5
enter_5	    btfss	PORTA,5
			goto	enter_5
			goto	enable_all_coins
press_select5
			btfsc	PORTA,4
			goto	coin1
select_5	btfss	PORTA,4
			goto	select_5
			goto	exit_to_start
exit_to_start
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
start1
			btfsc	PORTA,5
			goto	press_select4
enter_6		btfss	PORTA,5
			goto	enter_6
			goto	start		
press_select4
			btfsc	PORTA,4
			goto	start1
select_6	btfss	PORTA,4
			goto	select_6
			lcall	erase_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	press_enter

;************************************
enable_all_coins

		
	
		movlw	0x00
		call	XMIT_RS232
		movlw	0x02
		call	XMIT_RS232
		movlw	0x01
		call	XMIT_RS232
		movlw	0xE7
		call	XMIT_RS232
		movlw	0xFF
		call	XMIT_RS232
		movlw	0xFF
		call	XMIT_RS232
		movlw	0x18
		call	XMIT_RS232

		
		
		call	cleardisplay1
		lcall	coin_count
		bcf		PCLATH,3
		bcf		PCLATH,4
		lcall	coin
		bcf		PCLATH,3
		bcf		PCLATH,4
		lcall	route
		bcf		PCLATH,3
		bcf		PCLATH,4
		call	Delay_0.2
		call	Delay_0.2
		call	Delay_0.2
		call	Delay_0.2	;*********** added in delay ********23/06/17
		goto	test_coins
		
		
		

;************************************
		
erase_channels
			lcall	select_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	to_erase
			bcf		PCLATH,3
			bcf		PCLATH,4
			movlw	0x01
			movwf	erase_count
			call	display_erase_number
			goto	get_enter_pressed1	
get_enter_pressed1
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed1
			btfss	PORTA,5
			goto	$-1
			goto	erase_1
get_select_pressed1
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed1
			btfss	PORTA,4
			goto	$-1
			incf	erase_count
			call	display_erase_number

			movf	erase_count,w
			xorlw	0x11
			btfss	STATUS,Z
			goto	get_enter_pressed1
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_erase
get_enter_pressed_erase
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_erase
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed_erase
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_erase
			btfss	PORTA,4
			goto	$-1
			goto	erase_channels
		
erase_1
			movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0xA3
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0xA2
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0xA1
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0xA0
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9F
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9E
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9D
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9C
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9B
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0x9A
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0x99
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0x98
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0x97
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0x96
			movwf	crc
			goto	send_erase	
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0x95
			movwf	crc
			goto	send_erase
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0x94
			movwf	crc
			goto	send_erase
send_erase
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG		      
		movlw	0x02
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0x60
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0xF9
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	erase_count,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	crc,w  
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	


			lcall	finished
			bcf		PCLATH,3
			bcf		PCLATH,4
			call	_3_second_delay
			goto	erase_channels
;******************************************
display_erase_number
			movf	erase_count,w
			movwf	BIN
			movlw	0xC9
			movwf	address
			call	setaddress1
			call	BIN2BCD
			movf	tens,w
			call	senddata1
			movlw	0xCA
			movwf	address
			call	setaddress1
			movf	ones,w
			call	senddata1
			return


;******************************************			
programme_channels
			lcall	select_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	to_prog
			bcf		PCLATH,3
			bcf		PCLATH,4
			movlw	0x01
			movwf	erase_count
			call	display_erase_number
			goto	get_enter_press_1
get_enter_press_1
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_press_1
			btfss	PORTA,5
			goto	$-1
			goto	programme_1
get_select_press_1
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_press_1
			btfss	PORTA,4
			goto	$-1
			incf	erase_count
			call	display_erase_number

			movf	erase_count,w
			xorlw	0x11
			btfss	STATUS,Z
			goto	get_enter_press_1
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed171
get_enter_pressed171
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed171
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed171
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed171
			btfss	PORTA,4
			goto	$-1
			goto	programme_channels
;*******************************************
programme_1
			movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0x33
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0x32
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0x31
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0x30
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2F
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2E
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2D
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2C
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2B
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2A
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0x29
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0x28
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0x27
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0x26
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0x25
			movwf	crc
			goto	send_prog
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0x24
			movwf	crc
			goto	send_prog
send_prog
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG		      
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0xCA
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	erase_count,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	crc,w  
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		
		call	cleardisplay1
		lcall	start_coin_drop
		bcf		PCLATH,3
		bcf		PCLATH,4
		clrf	data1
		clrf	tens
		clrf	ones
		clrf	BIN
		
coin_drop
	MOVLW   b'00000000'
     	MOVWF   RCSTA  

 		MOVLW   b'10010000'
     	MOVWF   RCSTA  
		movlw	0x0B
		movwf	datacount
		movlw	0x30
		movwf	FSR
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0xE2
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x1D
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
	
		goto	rs232_2

rs232_2
			btfss   PIR1,	RCIF 	      ; check for received data
     		goto    rs232_2
		 	movf    RCREG,W
			movwf	INDF
			incf	FSR
			decfsz	datacount
			goto	rs232_2
			goto	display_coin_drop
			
display_coin_drop
			movlw	0xC7
			movwf	address
			call	setaddress1
			movf	data1,w
			movwf	BIN
			call	BIN2BCD
			movf	ones,w
			call	senddata1
			movf	data1,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	call_senddata
			goto	prog_finished
call_senddata
			
		
			call	Delay_0.2
			call	Delay_0.2
			goto	coin_drop


prog_finished
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		movlw	0xFE
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG
		lcall	finished
		bcf		PCLATH,3
		bcf		PCLATH,4
		call	_3_second_delay
		goto	programme_channels
;*******************************************



prog_1
	goto	prog_1


prog_id
			lcall	select_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	to_id
			bcf		PCLATH,3
			bcf		PCLATH,4
			movlw	0x01
			movwf	erase_count
			call	display_erase_number
			goto	get_enter_press_id1
get_enter_press_id1
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_press_id1
			btfss	PORTA,5
			goto	$-1
			goto	prog_id_1
get_select_press_id1
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_press_id1
			btfss	PORTA,4
			goto	$-1
			incf	erase_count
			call	display_erase_number
			movf	erase_count,w
			xorlw	0x11
			btfss	STATUS,Z
			goto	get_enter_press_id1
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id17
get_enter_pressed_id17
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id17
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed_id17
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id17
			btfss	PORTA,4
			goto	$-1
			goto	prog_id
;***************************************************
;***************************************************
prog_id_1
			movlw	0x01
			movwf	id_count
			lcall	select_id
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	gb200a
			bcf		PCLATH,3
			bcf		PCLATH,4
get_enter_pressed_id101
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id101
			btfss	PORTA,5
			goto	$-1
			goto	prog_id_101
get_select_pressed_id101
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id101
			btfss	PORTA,4
			goto	$-1
			lcall	gb100a
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id111
get_enter_pressed_id111
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id111
			btfss	PORTA,5
			goto	$-1
			movlw	0x02
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id111
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id111
			btfss	PORTA,4
			goto	$-1
			lcall	gb050a
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id121
get_enter_pressed_id121
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id121
			btfss	PORTA,5
			goto	$-1
			movlw	0x03
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id121
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id121
			btfss	PORTA,4
			goto	$-1
			lcall	gb020a
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id131
get_enter_pressed_id131
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id131
			btfss	PORTA,5
			goto	$-1
			movlw	0x04
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id131
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id131
			btfss	PORTA,4
			goto	$-1
			lcall	gb010a
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id141
get_enter_pressed_id141
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id141
			btfss	PORTA,5
			goto	$-1
			movlw	0x05
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id141
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id141
			btfss	PORTA,4
			goto	$-1
			lcall	gb005a
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id151
get_enter_pressed_id151
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id151
			btfss	PORTA,5
			goto	$-1
			movlw	0x06
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id151
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id151
			btfss	PORTA,4
			goto	$-1
			lcall	blank
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id161
get_enter_pressed_id161
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id161
			btfss	PORTA,5
			goto	$-1
			movlw	0x07
			movwf	id_count
			goto	prog_id_101
get_select_pressed_id161
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id161
			btfss	PORTA,4
			goto	$-1
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id171
get_enter_pressed_id171
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id171
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed_id171
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id171
			btfss	PORTA,4
			goto	$-1
			goto	prog_id_1
;***********************************************
prog_id_101
			call	cleardisplay
			movf	id_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	next
			goto	send_id_GB200A
next		movf	id_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	next1
			goto	send_id_GB100A
next1		movf	id_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	next2
			goto	send_id_GB050A
next2		movf	id_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	next3
			goto	send_id_GB020A
next3		movf	id_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	next4
			goto	send_id_GB010A
next4		movf	id_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	next5
			goto	send_id_GB005A
next5		movf	id_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	next6
			goto	send_id_BLANK
next6
			goto	next6
;*****************send channel id routine ********************
send_channel_id
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG		      
		movlw	0x07
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0xB9
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_No,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_1,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_2,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_3,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_4,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_5,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	channel_id_6,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	crc,w  
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	


			lcall	finished
			bcf		PCLATH,3
			bcf		PCLATH,4
			call	_3_second_delay
			goto	prog_id
	
;************************************************************		
send_id_GB200A
			
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_2
			movwf	channel_id_3
			movlw	_0
			movwf	channel_id_4
			movlw	_0
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
GB200A		movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE2
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE1
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE0
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDF
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDE
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDD
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDC
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDB
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDA
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD9
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD8
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD7
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD6
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD5
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD4
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD3
			movwf	crc
			goto	send_channel_id	
			
send_id_GB100A
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_1
			movwf	channel_id_3
			movlw	_0
			movwf	channel_id_4
			movlw	_0
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
GB100A		movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE3
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE2
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE1
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE0
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDF
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDE
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDD
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDC
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDB
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDA
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD9
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD8
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD7
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD6
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD5
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD4
			movwf	crc
			goto	send_channel_id	
send_id_GB050A
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_0
			movwf	channel_id_3
			movlw	_5
			movwf	channel_id_4
			movlw	_0
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
GB050A		movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDF
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0xE2
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDE
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDD
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDC
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDB
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0xDA
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD9
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD8
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD7
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD6
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD5
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD4
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD3
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD2
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0xD1
			movwf	crc
			goto	send_channel_id	
send_id_GB020A
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_0
			movwf	channel_id_3
			movlw	_2
			movwf	channel_id_4
			movlw	_0
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
			goto	GB200A
send_id_GB010A
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_0
			movwf	channel_id_3
			movlw	_1
			movwf	channel_id_4
			movlw	_0
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
			goto	GB100A
send_id_GB005A
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_g
			movwf	channel_id_1
			movlw	_b
			movwf	channel_id_2
			movlw	_0
			movwf	channel_id_3
			movlw	_0
			movwf	channel_id_4
			movlw	_5
			movwf	channel_id_5
			movlw	_a
			movwf	channel_id_6
			goto	GB050A
send_id_BLANK
			lcall	programming
			bcf		PCLATH,3
			bcf		PCLATH,4
			movf	erase_count,w
			movwf	channel_No
			movlw	_.
			movwf	channel_id_1
			movlw	_.
			movwf	channel_id_2
			movlw	_.
			movwf	channel_id_3
			movlw	_.
			movwf	channel_id_4
			movlw	_.
			movwf	channel_id_5
			movlw	_.
			movwf	channel_id_6
			movf	erase_count,w
			xorlw	0x01
			btfss	STATUS,Z
			goto	$+4
			movlw	0x2A
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x02
			btfss	STATUS,Z
			goto	$+4
			movlw	0x29
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x03
			btfss	STATUS,Z
			goto	$+4
			movlw	0x28
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x04
			btfss	STATUS,Z
			goto	$+4
			movlw	0x27
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	$+4
			movlw	0x26
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x06
			btfss	STATUS,Z
			goto	$+4
			movlw	0x25
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x07
			btfss	STATUS,Z
			goto	$+4
			movlw	0x24
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x08
			btfss	STATUS,Z
			goto	$+4
			movlw	0x23
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x09
			btfss	STATUS,Z
			goto	$+4
			movlw	0x22
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0A
			btfss	STATUS,Z
			goto	$+4
			movlw	0x21
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0B
			btfss	STATUS,Z
			goto	$+4
			movlw	0x20
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0C
			btfss	STATUS,Z
			goto	$+4
			movlw	0x1F
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0D
			btfss	STATUS,Z
			goto	$+4
			movlw	0x1E
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0E
			btfss	STATUS,Z
			goto	$+4
			movlw	0x1D
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x0F
			btfss	STATUS,Z
			goto	$+4
			movlw	0x1C
			movwf	crc
			goto	send_channel_id	
			movf	erase_count,w
			xorlw	0x10
			btfss	STATUS,Z
			goto	$+4
			movlw	0x1B
			movwf	crc
			goto	send_channel_id	
;**********************************************************************
;****************************************ROUTING***ROUTING***ROUTING***
;**********************************************************************
prog_routing
			lcall	cleardisplay
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	select_channel
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	to_route
			bcf		PCLATH,3
			bcf		PCLATH,4
			movlw	0x01
			movwf	erase_count
			call	display_erase_number
			goto	get_prog_routing
get_prog_routing
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_routing
			btfss	PORTA,5
			goto	$-1
			goto	prog_routing_ok
get_select_routing
			call	switch_delay
			btfsc	PORTA,4
			goto	get_prog_routing
			btfss	PORTA,4
			goto	$-1
			incf	erase_count
			call	display_erase_number
			movf	erase_count,w
			xorlw	0x11
			btfss	STATUS,Z
			goto	get_prog_routing
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id20
get_enter_pressed_id20
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id20
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed_id20
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id20
			btfss	PORTA,4
			goto	$-1
			goto	prog_routing

prog_routing_ok
			movf	erase_count,w
			movwf	route_channel
re_route	lcall	cleardisplay
			bcf		PCLATH,3
			bcf		PCLATH,4
			lcall	select_route
			bcf		PCLATH,3
			bcf		PCLATH,4
	
				
			movlw	0x01
			movwf	erase_count
			call	display_erase_number
			goto	get_routing
get_routing
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_routing1
			btfss	PORTA,5
			goto	$-1
			goto	prog_routing_ok1
get_select_routing1
			call	switch_delay
			btfsc	PORTA,4
			goto	get_routing
			btfss	PORTA,4
			goto	$-1
			incf	erase_count
			call	display_erase_number
			movf	erase_count,w
			xorlw	0x05
			btfss	STATUS,Z
			goto	get_routing
			lcall	exit
			bcf		PCLATH,3
			bcf		PCLATH,4
			goto	get_enter_pressed_id21
get_enter_pressed_id21
			call	switch_delay
			btfsc	PORTA,5
			goto	get_select_pressed_id21
			btfss	PORTA,5
			goto	$-1
			goto	wait3
get_select_pressed_id21
			call	switch_delay
			btfsc	PORTA,4
			goto	get_enter_pressed_id21
			btfss	PORTA,4
			goto	$-1
			goto	re_route

prog_routing_ok1
			movf	erase_count,w
			movwf	route_number
			movf	route_channel,w
			addwf	route_number,w
			addlw	0x27
			movwf	crc
			
			goto	send_routing
			;*************************** NOW HERE!!!!!!!!!****

send_routing
		movlw	0x00
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG		      
		movlw	0x02
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0x01
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movlw	0xD2
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	route_channel,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	route_number,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		movf	crc,w
		btfss   PIR1,	TXIF 	      
     	goto	$-1         
     	movwf   TXREG	
		lcall	finished
			bcf		PCLATH,3
			bcf		PCLATH,4
			call	_3_second_delay
			goto	prog_routing

test_coins


		MOVLW   b'00000000'
     	MOVWF   RCSTA  

 		MOVLW   b'10010000'
     	MOVWF   RCSTA   
		
		
		
	
		movlw	0x0E
		movwf	datacount
		movlw	0x30
		movwf	FSR

		movlw	0x00
		call	XMIT_RS232
		movlw	0x00
		call	XMIT_RS232
		movlw	0x01
		call	XMIT_RS232
		movlw	0xE5
		call	XMIT_RS232
		movlw	0x1A
		call	XMIT_RS232
	
		goto	rs232_1

rs232_1
			btfss   PIR1,	RCIF 	      ; check for received data
     		goto    rs232_1
		 	movf    RCREG,W
			movwf	INDF
			incf	FSR
			decfsz	datacount
			goto	rs232_1
			goto	senddata_count

senddata_count
			movf	data12,w
			movwf	BIN
			movlw	0x8B
			movwf	address
			call	setaddress1
			call	BIN2BCD
			movf	tens,w
			call	senddata1
			movlw	0x8C
			movwf	address
			call	setaddress1
			movf	ones,w
			call	senddata1
			goto	senddata_coin

senddata_coin
			movlw	0xC5
			movwf	address
			call	setaddress1
			movf	data13,w
			addlw	0x30
			call	senddata1
			goto	senddata_route
			
senddata_route
			movlw	0xCD
			movwf	address
			call	setaddress1
			movf	data14,w
			addlw	0x30
			call	senddata1
			call	Delay_0.2
			call	Delay_0.2
			call	Delay_0.2
			call	Delay_0.2
			goto	test_coins


BIN2BCD



;in: BIN
;out huns. tens, ones

;uses ADD-3 algoerthm

	movlw 8
	movwf countt
	clrf huns
	clrf tens
	clrf ones

BCDADD3

	movlw 5
	subwf huns, 0
	btfsc STATUS, C
	CALL ADD3HUNS
	movlw 5
	subwf tens, 0
	btfsc STATUS, C
	CALL ADD3TENS
	movlw 5
	subwf ones, 0
	btfsc STATUS, C
	CALL ADD3ONES
	decf countt, 1
	bcf STATUS, C
	rlf BIN, 1
	rlf ones, 1
	btfsc ones,4 ; 
	CALL CARRYONES
	rlf tens, 1
	btfsc tens,4 ; 
	CALL CARRYTENS
	rlf huns,1
	bcf STATUS, C
	movf countt, 0
	btfss STATUS, Z
	GOTO BCDADD3
	movf huns, 0 ; add ASCII Offset
	addlw h'30'
	movwf huns
	movf tens, 0 ; add ASCII Offset
	addlw h'30'
	movwf tens
	movf ones, 0 ; add ASCII Offset
	addlw h'30'
	movwf ones
	RETURN
ADD3HUNS
	movlw 3
	addwf huns,1
	RETURN
ADD3TENS
	movlw 3
	addwf tens,1
	RETURN
ADD3ONES
	movlw 3
	addwf ones,1
	RETURN
CARRYONES
	bcf ones, 4
	bsf STATUS, C
	RETURN
CARRYTENS
	bcf tens, 4
	bsf STATUS, C
	RETURN
;************ set data address routine page 0 *************
setaddress1
		movf  address,w	; address
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms_delay
		bcf	  PORTA,1
		return
	
	
;************ send data routine page 0 *************
senddata1
        movwf	PORTB
		bsf		PORTA,0
		bsf	  PORTA,1
		call  _100ms_delay
		bcf	  PORTA,1 
		return   
;*********** clear display routine page 0**********
cleardisplay1
		movlw 0x01
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms_delay
		bcf	  PORTA,1
		return

;********* NEW PAGE 0X800 ***********************
		org		0x800
;************************************************

sec_delay
	movlw	0x23
	movwf	count3
	movlw	0xB9
	movwf	count4
	movlw	0x09
	movwf	count5
sec_delay_1
	decfsz	count3, f
	goto	$+2
	decfsz	count4, f
	goto	$+2
	decfsz	count5, f
	goto	sec_delay_1

			;6 cycles
	goto	$+1
	goto	$+1
	goto	$+1
	return

;100ms delay

_100ms
		movlw	0x00		;1F
		movwf	count1
		movlw	0x08
		movwf	count2
delay1_00 
		decfsz	count1, f		; 100ms delay
		goto	$+2
		decfsz	count2, f
		goto	delay1_00
		goto	$+1
		return
;************ set data address routine *************
setaddress
		movf  address,w	; address
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms
		bcf	  PORTA,1
		return
	
	
;************ send data routine *************
senddata
        movwf	PORTB
		bsf		PORTA,0
		bsf	  PORTA,1
		call  _100ms
		bcf	  PORTA,1 
		return   
;*********** clear display routine **********
cleardisplay
		movlw 0x01
		movwf PORTB
		bcf	  PORTA,0
		bsf	  PORTA,1
		call  _100ms
		bcf	  PORTA,1
		return
;*********** display strings ****************
_not	
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_n
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	0x84
		movwf 	address
		call	setaddress
		return
_connected
		movlw	0x86
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_e
		call	senddata
		movlw	_d
		call	senddata
		return

name	
		call	cleardisplay
		movlw	0x84
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_l
		call	senddata
		movlw	_d
		call	senddata
		movlw	_r
		call	senddata
		movlw	_u
		call	senddata
		movlw	_s
		call	senddata
		movlw	_h
		call	senddata

		movlw	0xc3
		movwf 	address
		call	setaddress
		movlw	_p
		call	senddata	
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_g
		call	senddata
		movlw	_r
		call	senddata
		movlw	_a
		call	senddata
		movlw	_m
		call	senddata
		movlw	_m
		call	senddata
		movlw	_e
		call	senddata
		movlw	_r
		call	senddata
		return

initialise
		movlw	0x82
		movwf 	address
		call	setaddress
		movlw	_i
		call	senddata	
		movlw	_n
		call	senddata
		movlw	_i
		call	senddata
		movlw	_t
		call	senddata
		movlw	_i
		call	senddata
		movlw	_a
		call	senddata
		movlw	_l
		call	senddata
		movlw	_i
		call	senddata
		movlw	_s
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_g
		call	senddata
		return

connect_coin_mech

		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_m
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_h
		call	senddata
		return

sr5
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata
		movlw	_r
		call	senddata
		movlw	_5
		call	senddata
		movlw	_sp
		call	senddata
		return

sr5ie	
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata
		movlw	_r
		call	senddata
		movlw	_5
		call	senddata	
		movlw	_sp
		call	senddata
		movlw	_i
		call	senddata
		movlw	_slash
		call	senddata
		movlw	_e
		call	senddata
		movlw	_sp
		call	senddata
		return





connecting_now
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_g
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		return

check_connection
		
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_h
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_k
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata	
		movlw	_n
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_i
		call	senddata
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata
		return

then_press_enter
		movlw	0xc0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_h
		call	senddata
		movlw	_e
		call	senddata
		movlw	_n
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_p
		call	senddata
		movlw	_r
		call	senddata
		movlw	_e
		call	senddata
		movlw	_s
		call	senddata
		movlw	_s
		call	senddata
		movlw	_sp
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_n
		call	senddata
		movlw	_t
		call	senddata
		movlw	_e
		call	senddata
		movlw	_r
		call	senddata
	
		return
		
select_option
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_o
		call	senddata
		movlw	_p
		call	senddata
		movlw	_t
		call	senddata
		movlw	_i
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_n
		call	senddata
		return	

select_route
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_u
		call	senddata
		movlw	_t
		call	senddata	
		movlw	_e
		call	senddata
		return	

erase_channel
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_e
		call	senddata	
		movlw	_r
		call	senddata
		movlw	_a
		call	senddata
		movlw	_s
		call	senddata
		movlw	_e
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_h
		call	senddata
		movlw	_a
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		return	

prog_channel
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_p
		call	senddata	
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_g
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_h
		call	senddata
		movlw	_a
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		movlw	_sp
		call	senddata
		return	

set_coin_id
	
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_i
		call	senddata
		movlw	_d
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata	
		return	

set_routing
	
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_u
		call	senddata
		movlw	_t
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_g
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata	
		return	

exit
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_e
		call	senddata	
		movlw	_x
		call	senddata
		movlw	_i
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		return

test_coin
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_s
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_s
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_sp
		call	senddata
		return

coin_count
		
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_u
		call	senddata
		movlw	_n
		call	senddata
		movlw	_t
		call	senddata
		return

coin
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_c
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		return



route	
		movlw	0xC7
		movwf 	address
		call	setaddress
		movlw	_r
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_u
		call	senddata
		movlw	_t
		call	senddata
		movlw	_e
		call	senddata
		return

select_channel
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_h
		call	senddata	
		movlw	_a
		call	senddata
		movlw	_n
		call	senddata
		movlw	_n
		call	senddata
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		return

to_erase
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_e
		call	senddata
		movlw	_r
		call	senddata
		movlw	_a
		call	senddata
		movlw	_s
		call	senddata
		movlw	_e
		call	senddata
		return

to_prog
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_p
		call	senddata
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_g
		call	senddata
		return

to_route
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_r
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_u
		call	senddata
		movlw	_t
		call	senddata
		movlw	_e
		call	senddata
		return

to_id
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_t
		call	senddata	
		movlw	_o
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_i
		call	senddata
		movlw	_d
		call	senddata
		return

select_id
		call	cleardisplay
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_e
		call	senddata
		movlw	_l
		call	senddata
		movlw	_e
		call	senddata
		movlw	_c
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_i
		call	senddata
		movlw	_d
		call	senddata	
		return
gb200a
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_2
		call	senddata
		movlw	_0
		call	senddata
		movlw	_0
		call	senddata
		movlw	_a
		call	senddata
		return
gb100a
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_1
		call	senddata
		movlw	_0
		call	senddata
		movlw	_0
		call	senddata
		movlw	_a
		call	senddata
		return
gb050a
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_0
		call	senddata
		movlw	_5
		call	senddata
		movlw	_0
		call	senddata
		movlw	_a
		call	senddata
		return
gb020a
	
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_0
		call	senddata
		movlw	_2
		call	senddata
		movlw	_0
		call	senddata
		movlw	_a
		call	senddata
		return
gb010a
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_0
		call	senddata
		movlw	_1
		call	senddata
		movlw	_0
		call	senddata
		movlw	_a
		call	senddata
		return
gb005a
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_g
		call	senddata	
		movlw	_b
		call	senddata
		movlw	_0
		call	senddata
		movlw	_0
		call	senddata
		movlw	_5
		call	senddata
		movlw	_a
		call	senddata
		return
blank
		
		movlw	0xC0
		movwf 	address
		call	setaddress
		movlw	_b
		call	senddata	
		movlw	_l
		call	senddata
		movlw	_a
		call	senddata
		movlw	_n
		call	senddata
		movlw	_k
		call	senddata
		movlw	_sp
		call	senddata
		return

programming
		call	cleardisplay
		movlw	0x82
		movwf 	address
		call	setaddress
		movlw	_p
		call	senddata	
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_g
		call	senddata
		movlw	_r
		call	senddata
		movlw	_a
		call	senddata
		movlw	_m
		call	senddata
		movlw	_m
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_g
		call	senddata
		movlw	0xC3
		movwf 	address
		call	setaddress
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		call	sec_delay
		movlw	_star
		call	senddata
		return

finished
		call	cleardisplay
		movlw	0x84
		movwf 	address
		call	setaddress
		movlw	_f
		call	senddata	
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_i
		call	senddata
		movlw	_s
		call	senddata
		movlw	_h
		call	senddata
		movlw	_e
		call	senddata
		movlw	_d
		call	senddata
		return

start_coin_drop
		movlw	0x80
		movwf 	address
		call	setaddress
		movlw	_s
		call	senddata	
		movlw	_t
		call	senddata
		movlw	_a
		call	senddata
		movlw	_r
		call	senddata
		movlw	_t
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_c
		call	senddata
		movlw	_o
		call	senddata
		movlw	_i
		call	senddata
		movlw	_n
		call	senddata
		movlw	_sp
		call	senddata
		movlw	_d
		call	senddata
		movlw	_r
		call	senddata
		movlw	_o
		call	senddata
		movlw	_p
		call	senddata
		return

		end


[ Edited Tue Jul 04 2017, 04:36 AM ]
Sat Jun 24 2017, 08:24 PM
#2
Hi
Unfortunately there is too much code here to work on.
You need to narrow it down to the problem code.
Start by separating it into clearly defined sub routines.
Put the startup code into subroutines.
Separate the sub routines from the main program loop.
Comment every line of your code so that you and everyone else
knows what it should be doing.

Post your code as a zipped file, as shown on screen
it is very hard to follow.

If you can, post your Proteus project files as well.

Which assembler are you using ?
Sat Jun 24 2017, 08:47 PM
#3
Hi can you tell me how to send and recieve usart data every 200ms as in polling a device pic asm im using mpasm
Mon Jun 26 2017, 08:42 PM
#4
I have attached a demonstration file.
It will echo anything sent to the serial port.
It can use continuous polling or an interrupt.
I have marked the 3 lines you need to enable or disable to use either method.

When using on real hardware check that the configuration bits are being
programmed properly

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Nov 08 2017, 07:05 PM
Anirudh jain
I want to burn code in atmel 89s51 24pc 0329 but cannot get the connection with the burner. Can somebody provide me with the circuit diagram for connecting controller to burner. I'm using usb burner
Thu Nov 02 2017, 05:14 PM
karpal
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 11:17 PM
sanae
i am using the DHT11 but i'm getting some errors in the simulate the programe in proteus 8 professional,: 1)cannot find model file 'DHTXX.MDF'.2)simulation failed due to netlist linker error(s).
Fri Sep 29 2017, 08:15 AM
Maaz
i am doing the same project on verilog please contact me [email protected]
Wed Sep 20 2017, 06:06 AM
Ted
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 07:59 PM
martymarty
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
poojab51296
Sun Aug 20 2017, 03:53 PM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
poojab51296
Sun Aug 20 2017, 03:52 PM
hello
rawat742
Fri Aug 18 2017, 05:07 PM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Tue Aug 15 2017, 03:27 AM
@ angel patel... just log in and post your problem

Downloads

Comments

Wed Nov 15 2017, 10:46 AM
Ansh12
Sat Nov 11 2017, 03:43 AM
AngelGT93
Fri Nov 10 2017, 06:53 AM
JardCrocker
Wed Nov 08 2017, 05:27 PM
vivitern
Tue Nov 07 2017, 09:08 AM
catrons
Sat Nov 04 2017, 10:46 PM
JFTech
Fri Nov 03 2017, 05:58 AM
Sindhuspoo
Wed Nov 01 2017, 04:32 AM

Online

Guests: 61, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37916
Newest member: [email protected]
Forum Activity
Ansh12 Avatar
Posted By Ansh12
Fri Nov 17 2017, 04:07 AM
I am looking keypad interfacing program. I was rea...
JardCrocker Avatar
Posted By JardCrocker
Wed Nov 08 2017, 05:29 PM
Hi...i am a new user here. I was also facing the s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 07 2017, 07:13 PM
> It employs a fairly advanced technique to detect...
vivitern Avatar
Posted By vivitern
Tue Nov 07 2017, 09:33 AM
I own a used Clavia ddrum4 SE drum module. It empl...
bvdb Avatar
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...
Help Avatar
Posted By Help
Sun Oct 15 2017, 03:21 AM
AT+POP3READ=? +POP3READ: (1-1460) OK AT+POP3READ=...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Oct 14 2017, 08:06 PM
What happens if you ask for the full email ieAT+PO...
Help Avatar
Posted By Help
Sat Oct 14 2017, 02:28 AM
Dear all, AT // OK // 3.1 Bearer profile // Conf...