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
For reference, device PIC16C72
entry to routine is with ADRES freshly captured. That bit seems okay.
movlw .176 ; threshold
goto SECTION_C ; = below decimal 176
movlw .198 ; threshold
goto SECTION_B ; = between 176 and 198 decimal
movlw .221 ; threshold
goto SECTION_A ; = between 198 and 221 decimal
... it must be above 221 decimal then
> 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
email@example.com <MITVMA.MIT.EDU> wrote: PICLIST
> > 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
No, no, no... "SUBWF" subtracts W from ADRES.
The code works fine as originally written.
=== Andrew Warren - ix.netcom.comfastfwd
=== Fast Forward Engineering - San Diego, California
Yes, sorry, this gets me again and again - anyone want to buy (ab)used
On Fri, 5 May 2000, Andrew Warren wrote:
|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
;w = ADRES - 176 = ADRES + (256 - 176) = ADRES + 80
goto SECTION_C ;ADRES < 176
;numbers 176-255 now start from 0
;w = w - 22 = w + 234
goto SECTION_B ;176 <= ADRES < 198
;numbers 198-255 now start from 0
goto SECTION_A ;198 <= ADRES < 221
Hint: ready to pack into a macro :)
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- New search...