Truncated match.
PICList
Thread
'Window Detection'
2000\05\05@122559
by
Kevin Blain
I am having trouble with window detection - using the subwf function. It
looks to me very much like the following code section should work, but then
again, have I just been staring at it too long?
I am using interrupts - Yes, I am preserving all the right registers, but
could the C flag be getting corrupted is teh interrupt occurs during the
skpc instruction???
For reference, device PIC16C72
entry to routine is with ADRES freshly captured. That bit seems okay.
movlw .176 ; threshold
subwf ADRES,w
skpc
goto SECTION_C ; = below decimal 176
movlw .198 ; threshold
subwf ADRES,w
skpc
goto SECTION_B ; = between 176 and 198 decimal
movlw .221 ; threshold
subwf ADRES,w
skpc
goto SECTION_A ; = between 198 and 221 decimal
... it must be above 221 decimal then
subroutines...
SECTION_A:
stuff
SECTION_B:
stuff
SECTION_C:
stuff
2000\05\05@125738
by
rleggitt
> movlw .176 ; threshold
> subwf ADRES,w <- this subtracts ADRES from 176
> skpc <- carry is set if NO borrow, i.e. ADRES <= 176
Change to skpnc's -- Rich
2000\05\05@144523
by
Andrew Warren
2000\05\05@150755
by
rleggitt
Yes, sorry, this gets me again and again - anyone want to buy (ab)used
brain, cheap?
-- Rich
On Fri, 5 May 2000, Andrew Warren wrote:
{Quote hidden}
2000\05\06@034443
by
Nikolai Golovchenko
|
On Friday, May 05, 2000 Kevin Blain wrote:
> I am having trouble with window detection - using the subwf function. It
> looks to me very much like the following code section should work, but then
> again, have I just been staring at it too long?
Looks like you did it right.
> I am using interrupts - Yes, I am preserving all the right registers, but
> could the C flag be getting corrupted is teh interrupt occurs during the
> skpc instruction???
Interrupt can't occur during skpc execution. Two cycle instructions
are executed actually in one cycle, the other cycle is dummy, during
which the next instruction is fetched. So even if C flag gets
corrupted by interrupt, it can happen only between instructions.
Just make the registers saving/restoring in interrupt by the book and
you must be safe.
> For reference, device PIC16C72
> entry to routine is with ADRES freshly captured. That bit seems okay.
BTW, you can make the program a bit shorter:
Radix = DEC
movf ADRES, w ;w = ADRES
addlw -176
;w = ADRES - 176 = ADRES + (256 - 176) = ADRES + 80
skpc
goto SECTION_C ;ADRES < 176
;numbers 176-255 now start from 0
addlw -(198-176)
;w = w - 22 = w + 234
skpc
goto SECTION_B ;176 <= ADRES < 198
;numbers 198-255 now start from 0
addlw -(221-198)
skpc
goto SECTION_A ;198 <= ADRES < 221
Hint: ready to pack into a macro :)
<snip>
Nikolai
http://techref.massmind.org/member/NG--944
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...