;********************************************************************** ; 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
; 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 TENMSL
equ D'13' equ D'250'
*
;********************************************************************** ORG 0x000 ; processor reset vector clrf PCLATH nop ; nop required for icd goto start ; go to beginning of program ORG
0x004
movwf movf movwf movf movwf
w_temp STATUS,w status_temp PCLATH,w pclath_temp
; interrupt vector location ; save off current W register contents ; move status register into W register ; save off contents of STATUS register ; move pclath register into w register ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere movf pclath_temp,w movwf PCLATH movf status_temp,w movwf STATUS swapf w_temp,f swapf w_temp,w retfie
; retrieve copy of PCLATH register ; restore pre-isr PCLATH register contents ; retrieve copy of STATUS register ; restore pre-isr STATUS register contents ; restore pre-isr W register contents ; 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 ;movwf ip2 ; I/P RECIVER DATA
DATA
MOVF ip1,w ANDLW 0x08 ; cpu dc fuse MOVWF ip2 movlw 0x08 ; comparision of I/P data = 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
cpu
fuse
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 ANDLW 0x40 MOVWF ip2
;
cpu dc
fuse
DATA
movlw 0x40 ; comparision of I/P data = XORWF ip2,0 BTFSC STATUS,Z goto p21 ; data0 MOVLW 0xee ; faulty motor not gate MOVWF CP1 COMF CP1,0 MOVWF PORTA CALL ldly2
cpu
i/p =
fuse
13
0/p = 12
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
faulty
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 movwf movlw movwf ten
.13 COUNTH .245 COUNTL
decfsz COUNTL,F goto ten decfsz COUNTH,F goto ten return
tenms1 nop movlw movwf movlw movwf ten1
ldly
.19 COUNTH1 .245 COUNTL1
decfsz COUNTL,F goto ten1 decfsz COUNTH,F goto ten1 return
call tenms call tenms call tenms call tenms
call call call call call call call call call call
tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms
call call call call call call call call call call call call call call call call
tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms 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 call call call call call call call call call call call call call call
tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms tenms
call tenms return lcd1 BANKSEL MH movlw 0x82 ; call lcdout call tenms movlw 'O' ; call asc call tenms movlw 'n' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd2
BANKSEL MH movlw 0x82 ; call lcdout call tenms movlw 'O' ; call asc call tenms movlw 'F' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd3 BANKSEL MH movlw 0x88 ; call lcdout call tenms movlw 'D' ; call asc call tenms movlw 'r' call asc call tenms RETURN lcd4 BANKSEL MH
;
COMMAND
R
A
MODE
movlw 0x88 ; call lcdout call tenms movlw 'O' ; call asc call tenms movlw 'k' call asc call tenms
COMMAND
MODE
R
;
A
RETURN lcd5
BANKSEL MH movlw 0x8D ; call lcdout call tenms movlw 'O' ; call asc call tenms movlw 'v' call asc call tenms
COMMAND
MODE
R
;
movlw 'L' call asc call tenms
A
;
A
RETURN lcd6 BANKSEL MH movlw 0x8D ; call lcdout call tenms movlw 'R' ; call asc call tenms movlw 'n' call asc call tenms movlw 'g' call asc call tenms RETURN lcd7
COMMAND
R
;
A
;
A
MODE
BANKSEL MH movlw 0xc3 ; call lcdout call tenms movlw '1' ; call asc call tenms movlw 'd' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd8
BANKSEL MH movlw 0xc3 ; call lcdout call tenms movlw '1' ; call asc call tenms movlw 'w' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd9 BANKSEL MH movlw 0xc6 ; call lcdout call tenms movlw '2' ; call asc call tenms movlw 'd' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd10
BANKSEL MH movlw 0xc6 ; call lcdout call tenms
COMMAND
MODE
movlw '2' ; call asc call tenms movlw 'w' call asc call tenms
;
R
A
RETURN lcd11 BANKSEL MH movlw 0xc9 ; call lcdout call tenms movlw '3' ; call asc call tenms movlw 'd' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd12
BANKSEL MH movlw 0xc9 ; call lcdout call tenms movlw '3' ; call asc call tenms movlw 'w' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd13 BANKSEL MH movlw 0xcc ; call lcdout call tenms movlw '4' ; call asc call tenms movlw 'd' call asc call tenms
;
COMMAND
R
A
MODE
RETURN lcd14 BANKSEL MH movlw 0xcc ; call lcdout call tenms movlw '4' ; call asc call tenms movlw 'w' call asc call tenms
;
COMMAND
MODE
R
A
RETURN lcd15
BANKSEL MH movlw 0xcf ; call lcdout call tenms movlw 'R' ; call asc call tenms
COMMAND
MODE
R
RETURN lcd16 BANKSEL MH movlw 0xcf ; call lcdout call tenms movlw 'C' ; call asc call tenms
COMMAND
MODE
R
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 bsf PORTE,1 bcf PORTE,1 call tenms bsf PORTE,0 return asc
movwf PORTD bsf PORTE,0 bsf PORTE,1 bcf PORTE,1 call tenms bcf PORTE,0 return
; ; ;
2 - PORTC 3 - PORTC 3 - PORTC
;
2 - PORTC
; ; ;
2 - PORTC 3 - PORTC 3 - PORTC
;
2 - PORTC
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 ; bcf PORTE,1 call tenms bcf PORTE,0 return ldly2 call call call call call call call
ldly ldly ldly ldly ldly ldly ldly
3 - PORTC ; 3 - PORTC ;
2 - PORTC
; 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'