the idea is to compare the input value with setpoints (SP) value and turn ON the LED for appropriate setpoints
Input > SP1 = LED1 On
Input > SP2 = LED2 On
Input > SP3 = LED3 On
by simulate using MPLAB (MPSIM), i found my 'test' routines have problem...but do not know how should i solve it..
here the code
pls help me
thanks in advance
Input > SP1 = LED1 On
Input > SP2 = LED2 On
Input > SP3 = LED3 On
by simulate using MPLAB (MPSIM), i found my 'test' routines have problem...but do not know how should i solve it..
here the code
pls help me
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Author : alamy
;Date : 22/10/04
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__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
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 20h
SP0 EQU 21h
SP1 EQU 22h
SP2 EQU 23h
;*************************************************************
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'11111111' ; set the port b as inputs
movwf TRISB ;
movlw b'00000000' ; set the port a as outputs
movwf TRISA
bcf STATUS,5 ; bank 1 -----> bank 0
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;setting setpoint
setpoint
movlw .15
movwf SP0
movlw .32
movwf SP1
movlw .48
movwf SP2
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
read
movf PORTB,w
movwf TempW
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;test input with setpoints
Test
btfss TempW,SP0 ; TempW > SP0 ?
goto Out1 ; No!
btfss TempW,SP1 ; TempW > SP1 ?
goto Out2 ; No!
btfss TempW,SP2 ; TempW > SP2 ?
goto Out3 ; No!
goto Test ; Retry
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Out1 movlw 1
movwf PORTA
goto read
Out2 movlw 2
movwf PORTA
goto read
Out3 movlw 3
movwf PORTA
goto read
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
END ; directive 'end of program'
thanks in advance