Truncated match.
PICList
Thread
'Why, oh why...'
1998\04\07@043155
by
n Midgley
|
...doesn't this work?
Dear all
Having served the first part of my pic apprenticeship (making leds flash,
counting on 7 segment displays, etc), I've moved on to meatier things.
My first stab was aimed at producing a measurement of a pulse length
(yes, alright dammit, it's a R/C thing!). Despite extensive de-bugging,
and appearing to work on MPSIM, the wretched thing keeps saying '00'. So,
back to the drawing board, how about an interrupt driven program that just
mirrors the input to an output pin? Here's my version (I'm sure it could be
done in 4 1/2 bytes of program code, but it mirrors the way my other prog's
supposed to work):
list p=16f84
#include "c:\progra~1\mplab\p16f84.inc"
left equ 0x0f
right equ 0x10
_w equ 0x11
_status equ 0x12
; You can assume WDT Off, PWRTE On, XT, 4Mhz Resonator
org 0
goto main
org 4
; interrupt routine
movwf _w ; save w
movf status,w ; and status
movwf _status
bcf intcon,intf ;
bsf status,rp0
btfss option_reg,intedg ; are we here for a rising or
goto pulse_off ; falling edge
pulse_on
bcf option_reg,intedg ; next time, a falling edge
bcf status,rp0
bsf porta,2 ; turn on a pin to match rb:0
goto int_exit
pulse_off
bsf option_reg,intedg ; next time, a rising edge
bcf status,rp0
bcf porta,2 ; turn off to match rb:0
int_exit
movf _status,w ; the usual gubbins
movwf status
swapf _w
swapf _w,w ;
retfie
main
clrf tmr0
bsf status,rp0
clrw
movwf trisa ; make porta outputs (they are anyway?)
movlw 1
movwf trisb ; make rb:0 an input
movlw b'11000000' ; wait for rising edge on rb:0
movwf option_reg
bcf status,rp0
movlw b'10010000' ; GIE and inte set
movwf intcon
clrw
movwf left ; stuff left over from my digit
movwf right ; displaying routines
clrf porta
clrf portb ; does clrfing portb cause a problem?
loop goto loop ; hang about
end
Again, it works on the simulator, toggling RB:0, but in 'real
life', all pins except RB:0 sit dormant. Can anyone suggest
why?
Regards
John M
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- Today
- New search...