![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Micro: 18F Microchip family. Given a common register, to detect the transition from 0 to 255 (DECF), what can I test? Is it any trick other than looking for the value 255 in the byte?
__________________ Agustín Tomás In theory, there is no difference between theory and practice. In practice, however, there is. | |
| |
| | (permalink) |
| Try looking at the flags register!. | |
| |
| | (permalink) |
| Going from 255 to 0 sets C but the opposite has not a single flag set, only for the case. At least, simulation shows that.
__________________ Agustín Tomás In theory, there is no difference between theory and practice. In practice, however, there is. | |
| |
| | (permalink) |
| Doesn't it set the overflow flag? Mike. | |
| |
| | (permalink) |
| The DECF instruction on a reg with a value of zero to 255 sets the Negative flag (Status reg bit 4) | |
| |
| | (permalink) |
| Wouldn't it also clear the Zero flag bit? Yep, the DECF instructions affects a whole bunch of STATUS bits. Check out the instruction set summary. Mike Last edited by Mike, K8LH; 28th January 2007 at 02:44 PM. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| I wonder if the OP is trying to avoid decrementing a register if its value is 0? If that's the case, most of us recommend testing for that condition before performing the decrement operation. Isn't that right guys? Mike | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
tstfsz reg ; skip if the reg has already reached zero decf reg,f If he wants to test if a reg has reached 255, then he could use: DECF reg,f BN destination ; Branch if negative | ||
| |
| | (permalink) |
| How about decf file,F incfsnz file,W ; check if file was zero before the decrement goto WasZero Or OV=1 and N=1 gives the same thing. Checking Z=0 will give all numbers except zero. Checking N=1 will give all numbers from 0x80 to 0xff. Checking just OV will give 255 and 127. Someone with more knowledge about 18 code, does the Carry flag act as a borrow and is therefore reset only if there is a transition from 0 to 255? This would seem likely to me. Mike. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Sytem Testing | -=GST=- Nemisis (cs/cz) | Electronic Projects Design/Ideas/Reviews | 3 | 3rd April 2006 02:00 PM |
| know about testing tools | arun_dexter | General Electronics Chat | 1 | 15th May 2005 07:55 AM |
| testing a thermocouple | evandude | General Electronics Chat | 8 | 29th October 2004 05:25 PM |
| Capacitor testing | zachtheterrible | General Electronics Chat | 9 | 31st May 2004 07:21 AM |
| Testing any Monitor Without PC | xpacer | General Electronics Chat | 6 | 13th July 2003 09:55 AM |