I am relatively new at programming PICS and I
have encountered my first uncrackable bug!
I am using the 16F84 chip at 4MHz
with just the TMR0 overflow interrupt enabled. The first four bits in portb are
defined as inputs and rest as outputs, the portb pullups are also enabled. This
initialisation can be seen below.
set_bank0 ;
macro
movlw 00100000b ;
set interrupts
movwf
intcon ; timer on, global
off
set_bank1 ;
macro
; set options : prescaler to WD.
; only one prescaler so
timer now driven direct from clock.
; timer period = 0.256
mS.
; bit5 clear to select timer mode
; Turn Port B pullups
on. Bit 7.
movlw
00001111b ; set
OPTIONs
movwf optionreg
movlw
00011100b ; 5 bits only on port
A
movwf
TRISA ; 0 & 1
outputs
movlw
00001111b ; set port
B
movwf TRISB ; 4,5,6 & 7
outputs
set_bank0 ; macro
; set o/ps safe
movlw
00000010b
movwf portA ; set TX power off
movlw 00000000b
; set adc /CS hi
movwf portB
;etc
My problem is: I can't seem to control IO
pin 10 in a certain region of code. The instruction I am using is as follows:
bcf portB,4. Pin 10 is only connected to a 0.1uF cap which goes to 0v. Below is
the code showing where I have placed the command with comments showing where it
worked and did not work.
; portB,4 is high at this point
intoff ; stop
interrupts - macro that disables int
;#t bcf portB,4 ; it worked here
movfw CC ; set int
timers
movwf time_hi
movfw BB
movwf time_mid
movfw AA
;#t bcf
portB,4 ; it worked here
movwf time_lo
movlw synctime ;
set the resync delay timer for one hour.
;#t bcf portB,4 ; it worked
here
movwf time_s ;
;#t bcf portB,4 ; it
did not work
here
inton
; macro turns all ints on
;#tbcf portB,4 ; it
did not work here ;turn off MSF radio.
bsf
shift_out,6 ; RED LED off to show sync found
call load_shift ;
routine that moves the byte shift_out into a shift reg
;#t
bcf portB,4 ;worked here
I have spent a 2 days looking at this and still
can't figure it out. I know I have done something completely stupid but I can't
work out what!
Any help will be greatly
appreciated.
Alan