;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
cblock
d1
d2
d3
d4
count1
endc
; '__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.
;###############################################
; CIRCUIT FUNCTION
; to implement the inference engine for digital fuzzy controller to control
; the compressor action.
; single means - off, low , medium or high
;###############################################
;***** VARIABLE DEFINITIONS
STATUS EQU 03h ; variable used for context saving
TRISA EQU 85h ; variable used for context saving
PORTA EQU 05H
TRISB EQU 86h
PORTB EQU 06h
TempW EQU 1
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
main bsf STATUS,5 ; bank 0 -----> bank 1
movlw b'00000000' ; set the port a as outputs
movwf TRISA ;
movlw b'00111111' ; set the port b as inputs
movwf TRISB
bcf STATUS,5 ; bank 1 -----> bank 0
Read movf PORTB,w
movwf TempW
Btfss TempW, 5 ; test bit 5
Goto TurnOn
Goto TurnOff
TurnOn andlw b'00011111'; should i change to b'00111111', 32 or 64 bytes?
Call TableOn
Call DelayW
bcf PORTA
Goto Read
TurnOff andlw b'00011111
Call TableOff
Call DelayW
bsf PORTA
Goto Read
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
; Delay = 300 seconds
; Clock frequency = 4 MHz
; Actual delay = 300 seconds = 300000000 cycles
; Error = 0 %
DelayW movwf count1
Delay5 ;299999995 cycles
movlw 0x54
movwf d1
movlw 0xA1
movwf d2
movlw 0xFD
movwf d3
movlw 0x02
movwf d4
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto $+2
decfsz d4, f
goto Delay_0 ;5 cycles
goto $+1
goto $+1
nop
decfsz count1 ,f
goto Delay5
retlw 0x00
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
TableOff Addwf PCL,f
Retlw 1 ;0
Retlw 1 ;1
Retlw 2 ;2
Retlw 1 ;3
Retlw 3 ;4
Retlw 1 ;5
Retlw 1 ;6
Retlw 2 ;7
Retlw 1 ;8
Retlw 3 ; 9
Retlw 1 ;10
Retlw 1 ;11
Retlw 2 ;12
Retlw 1 ;13
Retlw 3 ;14
Retlw 1 ;15
Retlw 1 ;16
Retlw 2 ;17
Retlw 1 ;18
Retlw 3 ;19
Retlw 1 ;20
Retlw 1 ;21
Retlw 2 ;22
Retlw 1 ;23
Retlw 3 ;24
Retlw 1 ;25
Retlw 1 ;26
Retlw 2 ;27
Retlw 1 ;28
Retlw 3 ;29
Retlw 1 ;30
Retlw 3 ;31
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
TableOn Addwf PCL,f
Retlw 2 ;32
Retlw 2 ;33
Retlw 2 ;34
Retlw 2 ;35
Retlw 3 ;36
Retlw 3 ;37
Retlw 2 ;38
Retlw 2 ;39
Retlw 1 ;40
Retlw 3 ;41
Retlw 3 ;42
Retlw 2 ;43
Retlw 2 ;44
Retlw 1 ;45
Retlw 3 ;46
Retlw 1 ;47
Retlw 2 ;48
Retlw 2 ;49
Retlw 1 ;50
Retlw 3 ;51
Retlw 1 ;52
Retlw 1 ;53
Retlw 2 ;54
Retlw 1 ;55
Retlw 3 ;56
Retlw 2 ;57
Retlw 2 ;58
Retlw 2 ;59
Retlw 1 ;60
Retlw 3 ;61
Retlw 1 ;62
Retlw 2 ;63
END ; directive 'end of program'