You are on page 1of 14

;**********************************************************************

; HARDWARE
;This is the transmitter side of the fault anouncuator.It calculated some of
following functions.
; PA0 TO PA3 ==> TRANSMITTER O/P
; PC0 = OVER TEMP , PC1 == OVERLOAD , PC2 = MAINS FAIL
; PC3 = CPU SUPPLY PC4 = DC FUSE , PC5 = MCB
; PB0 = NOT GATE I/P PB1 = NOT GATE O/P *
;**********************************************************************
Filename:LCD877A.asm *
; Date: 25/02/2003 *
; File Version: 1.2 *
; Author: Free electronics projects
*
; Company: *
;**********************************************************************
; Notes: THIS IS TEST PROGRAM FOR LCD
*
; PD0 TO PD7 -->
*
;**********************************************************************
list p=16f877A ; list directive to define processor
#include <p16f877A.inc> ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_OFF & _XT_OSC & _WRT_OFF &
_LVP_OFF & _CPD_OFF

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

;******************************************************************
;***** VARIABLE DEFINITIONS
w_temp EQU 0x71 ; variable used for context saving
status_temp EQU 0x72 ; variable used for context saving
pclath_temp EQU 0x73 ; variable used for context saving

;**** TEMP RAM
cblock 0x24
COUNTH
COUNTL
COUNTH1
COUNTL1
count
ch
DH
MH
Dl
ip1 ; I/P RECIVER DATA
ip2 ; I/P RECIVER DATA
CP1
iip1
iip2

endc

TENMSH equ D'13'
TENMSL equ D'250'
;**********************************************************************
ORG 0x000 ; processor reset vector
clrf PCLATH
nop ; nop required for icd
goto start ; go to beginning of program

ORG 0x004 ; interrupt vector location

movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register

; isr code can go here or be located as a call subroutine elsewhere

movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt

; Start at the reset vector

start
banksel TRISC
movlw 0xFF
movwf TRISC

banksel TRISB
movlw 0xFF
movwf TRISB
banksel TRISD
movlw 0x00
movwf TRISD
banksel ADCON1 ;assembler directive to select bank
;set all PORTA pins as inputs
banksel ADCON1
movlw 0x06
MOVWF ADCON1
banksel TRISA
movlw 0x00
movwf TRISA

BANKSEL TRISE
MOVLW 0x00
movwf TRISE
banksel ch
movlw 0xFF
MOVWF PORTA
MOVLW 0x00
movwf PORTB
movwf PORTD
movwf PORTE
BSF PORTE,2
CALL ldly2
BCF PORTE,2
;call initlcd

main
banksel ch

up
BANKSEL MH
call tenms
movf PORTC,W
movwf ip1 ; ORIGNAL COMPARISION DATA
;movwf ip2 ; I/P RECIVER DATA

MOVF ip1,w
ANDLW 0x08 ; cpu dc fuse
MOVWF ip2
movlw 0x08 ; comparision of I/P data = cpu fuse
XORWF ip2,0
BTFSC STATUS,Z
goto p1 ; data0
MOVLW 0x22
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt2
MOVF ip1,w
ANDLW 0x20 ; mcb fail
MOVWF ip2
movlw 0x20; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p3 ; data0
MOVLW 0x44
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt5

MOVF ip1,w
ANDLW 0x04 ; ac fuse
MOVWF ip2
movlw 0x04 ; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p5 ; data1
MOVLW 0x66
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt7
MOVF ip1,w
ANDLW 0x10 ; dc fuse
MOVWF ip2
movlw 0x10 ; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p7 ; data4
MOVLW 0x88
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt9
MOVF ip1,w
ANDLW 0x01 ; over temp
MOVWF ip2
movlw 0x01; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p9 ; data5
MOVLW 0x99
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt11
MOVF ip1,w
ANDLW 0x02 ; over load
MOVWF ip2
movlw 0x02 ; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p11 ; data6
MOVLW 0xcc
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

nxt14
MOVF ip1,w
ANDLW 0x00 ; all ok
MOVWF ip2
movlw 0x00 ; comparision of I/P data
XORWF ip2,0
BTFSC STATUS,Z
goto p14 ; all ok

nxt18

movf ip1,w ; ORIGNAL COMPARISION DATA

ANDLW 0x40 ; cpu dc fuse
MOVWF ip2
movlw 0x40 ; comparision of I/P data = cpu fuse
XORWF ip2,0
BTFSC STATUS,Z
goto p21 ; data0
MOVLW 0xee ; faulty motor not gate i/p = 13 0/p = 12 faulty
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

goto up
;----------------------------------------------------------
p21
MOVLW 0xdd ; ok motor code
MOVWF CP1
COMF CP1,0

MOVWF PORTA
CALL ldly2
goto up

p1
MOVLW 0x11
MOVWF CP1
COMF CP1,0

MOVWF PORTA
CALL ldly2
GOTO nxt2

p3
MOVLW 0x33
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2
goto nxt5

p5
MOVLW 0x55
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2
goto nxt7

p7
MOVLW 0x77
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2
goto nxt9

p9
MOVLW 0xAA
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2
goto nxt11

p11
MOVLW 0xBB
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2
goto nxt14

p14
MOVLW 0xcc
MOVWF CP1
COMF CP1,0
MOVWF PORTA
CALL ldly2

goto nxt18

GOTO main
;--------------------------------------------------------------------

tenms
nop
movlw .13
movwf COUNTH
movlw .245
movwf COUNTL

ten
decfsz COUNTL,F
goto ten
decfsz COUNTH,F
goto ten
return

tenms1
nop
movlw .19
movwf COUNTH1
movlw .245
movwf COUNTL1

ten1
decfsz COUNTL,F
goto ten1
decfsz COUNTH,F
goto ten1
return

ldly
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms

call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms

call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms

call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms
call tenms

return

lcd1
BANKSEL MH

movlw 0x82 ; COMMAND MODE
call lcdout
call tenms

movlw 'O' ; R
call asc
call tenms

movlw 'n' ; A
call asc
call tenms

RETURN

lcd2
BANKSEL MH

movlw 0x82 ; COMMAND MODE
call lcdout
call tenms

movlw 'O' ; R
call asc
call tenms

movlw 'F' ; A
call asc
call tenms

RETURN

lcd3

BANKSEL MH

movlw 0x88 ; COMMAND MODE
call lcdout
call tenms

movlw 'D' ; R
call asc
call tenms

movlw 'r' ; A
call asc
call tenms

RETURN

lcd4
BANKSEL MH
movlw 0x88 ; COMMAND MODE
call lcdout
call tenms

movlw 'O' ; R
call asc
call tenms

movlw 'k' ; A
call asc
call tenms

RETURN

lcd5
BANKSEL MH

movlw 0x8D ; COMMAND MODE
call lcdout
call tenms

movlw 'O' ; R
call asc
call tenms

movlw 'v' ; A
call asc
call tenms

movlw 'L' ; A
call asc
call tenms

RETURN

lcd6
BANKSEL MH

movlw 0x8D ; COMMAND MODE
call lcdout
call tenms

movlw 'R' ; R
call asc
call tenms

movlw 'n' ; A
call asc
call tenms

movlw 'g' ; A
call asc
call tenms

RETURN

lcd7
BANKSEL MH

movlw 0xc3 ; COMMAND MODE
call lcdout
call tenms

movlw '1' ; R
call asc
call tenms

movlw 'd' ; A
call asc
call tenms

RETURN

lcd8
BANKSEL MH

movlw 0xc3 ; COMMAND MODE
call lcdout
call tenms

movlw '1' ; R
call asc
call tenms

movlw 'w' ; A
call asc
call tenms

RETURN

lcd9
BANKSEL MH

movlw 0xc6 ; COMMAND MODE
call lcdout
call tenms

movlw '2' ; R
call asc
call tenms

movlw 'd' ; A
call asc
call tenms

RETURN

lcd10
BANKSEL MH

movlw 0xc6 ; COMMAND MODE
call lcdout
call tenms
movlw '2' ; R
call asc
call tenms

movlw 'w' ; A
call asc
call tenms

RETURN

lcd11
BANKSEL MH

movlw 0xc9 ; COMMAND MODE
call lcdout
call tenms

movlw '3' ; R
call asc
call tenms

movlw 'd' ; A
call asc
call tenms

RETURN

lcd12
BANKSEL MH

movlw 0xc9 ; COMMAND MODE
call lcdout
call tenms

movlw '3' ; R
call asc
call tenms

movlw 'w' ; A
call asc
call tenms

RETURN

lcd13
BANKSEL MH

movlw 0xcc ; COMMAND MODE
call lcdout
call tenms

movlw '4' ; R
call asc
call tenms

movlw 'd' ; A
call asc
call tenms
RETURN

lcd14
BANKSEL MH

movlw 0xcc ; COMMAND MODE
call lcdout
call tenms

movlw '4' ; R
call asc
call tenms

movlw 'w' ; A
call asc
call tenms

RETURN

lcd15
BANKSEL MH

movlw 0xcf ; COMMAND MODE
call lcdout
call tenms

movlw 'R' ; R
call asc
call tenms

RETURN

lcd16
BANKSEL MH

movlw 0xcf ; COMMAND MODE
call lcdout
call tenms

movlw 'C' ; R
call asc
call tenms

RETURN

;----------------------------------------------------
;------------------------------------------------------
p0
; bsf PORTE,2
movf ip2,w
movwf PORTB
;call lcd0
call ldly
;call ldly
; call ldly
bcf PORTE,2
call tenms
clrf PORTB
goto up

lcdout
movwf PORTD
bcf PORTE,0 ; 2 - PORTC
bsf PORTE,1 ; 3 - PORTC
bcf PORTE,1 ; 3 - PORTC
call tenms
bsf PORTE,0 ; 2 - PORTC
return

asc
movwf PORTD
bsf PORTE,0 ; 2 - PORTC
bsf PORTE,1 ; 3 - PORTC
bcf PORTE,1 ; 3 - PORTC
call tenms
bcf PORTE,0 ; 2 - PORTC
return

ldly2

call ldly
call ldly
call ldly
call ldly
call ldly
call ldly
call ldly
; call ldly
;call ldly
; call ldly
;call ldly
return

; remaining code goes here
end ; directive 'end of program'
; remaining code goes here

; directive 'end of program'

bsf PORTE,1 ; 3 - PORTC
bcf PORTE,1 ; 3 - PORTC
call tenms
bcf PORTE,0 ; 2 - PORTC
return

ldly2

call ldly
call ldly
call ldly
call ldly
call ldly
call ldly
call ldly
; call ldly
;call ldly
; call ldly
;call ldly
return

; remaining code goes here

end ; directive 'end of program'
; remaining code goes here ; directive 'end of program'