for some reason the led won't turn on at any time.
Could it be because i'm using an external clock
btw: if you know a better way to make a pull-down
resister let me know.
;
; Note: change the "P509 EQU 0"
to "P509 EQU 1" below to instruct
; the
assembler to make the hex object code for a
PIC12C509.
;
P509
EQU 0 ;Default
assembles for a PIC12C508
IF
P509
list p=12c509
include
"p12c509.inc"
ELSE
list
p=12c508
include
"p12c508.inc"
ENDIF
radix
dec
WIRE5 EQU
1 ;Default assembles to 4-wire
version
IF WIRE5
__FUSES
_MCLRE_OFF & _CP_ON & _WDT_OFF &
_XT_OSC ;5-wire
ELSE
__FUSES _MCLRE_OFF & _CP_ON & _WDT_OFF
& _IntRC_OSC ;4-wire
ENDIF
cblock 0x07 ;Store variables above control registers
m ;Loop
counters
j
k ;/
x ;Used by delay
routine
y
;/
i ;
z ;
u ;
xmit ;Transmit data
holding register
index ;Index
register for table lookups
func1 ;
func2 ;flags
func3 ;
func4 ;
func5 ;
mode4 ;flag for 4 wire
mode
mode ;
endc
;
#############################################
; ### Note... pins can be
swapped around by ###
; ### changing defines below now , makes it ###
;
### simpler to modify ................. ###
;
#############################################
#define door GPIO,0 ; whenever
reset is used it is replaced
#define gate
GPIO,2 ; by GPIO,3 now..... ditto for the others
#define
reset GPIO,3 ;
#define led GPIO,4 ;led active
when chip active
option
#define speed GPIO,5
movwf
OSCCAL ;Set oscillator
calibration reg.
movlw
b'11000010' ;Set TMR0 prescaler = 1:8
(f_osc=4MHz)
option
;and enable pull-ups
goto boot
org 0x8
dt '5','W','i','r','e','2','.','0'
;####################################
;######## TURNS THE LED ON
##########
;####################################
boot
movlw b'11101111' ; sets all pin as inputs
exept pin 3
tris
GPIO ;turns led
on
bsf led
movlw b'11111111'
movwf mode4
;###############################################
;###
DELAYS TO ALLOW for noise in the switch ###
;###############################################
movlw
10 ;10*50 =
0.5sec
movwf
i ;to
allow for noise in the switch
dlyres call dly_50 ;otherwise the
disable
decfsz i,F
;check doesn't work properly
goto dlyres
;#########################################
;##### CHECK
THE DOOR TO SEE IF USER #####
;##### WANTS THE
CHIP DISABLED #####
;#########################################
movlw 50
;50*50 = 2.5sec
movwf i
;checks the door for 2 sec
dischk call dly_50 ;Delay
50ms
bcf door ;set
low initally to force recongition
movlw b'11101111' ;fake a pull-down
resister
tris
GPIO ;
bcf door
btfss
door ;Check door skip if
up
goto
start ;if door closed Jump into main code
segment
decfsz i,F ;decrement
i skip if 0
goto
dischk ; check door every
50ms
goto
disable
goto start