What about using
Code:andlw 0x2F0 ; Are we done? (We're done when bit2 of btfsc STATUS,Z ; the high order byte overflows to 1).
What about using
Code:andlw 0x2F0 ; Are we done? (We're done when bit2 of btfsc STATUS,Z ; the high order byte overflows to 1).
No, you can only check one byte(8bits) in one go. You're also trying to check several bits at the same time, only one is "allowed". If you really MUST check for something more complicated you'll need to rewrite the code yourself. Certanly possible but nothing i will help you with.
Good luck.
/Ingvar
PS. Is there a perticular reason why you can't use 10 bits and scale the result as i showed you in my last post? DS.
Where is the result stored - in result_l or result_h or are they the same ?
At U = Umax there should be a value of 1024.
Result_h is the high byte(8bits) of the wordsized(16bits) result. Result_l holds the lower 8 bits.
I don't understand this. How do you combine these two to get a Dez-number between 0 and 1023 ?
Ok, time for somebody else to step in. I don't have the patience, time and/or languageskills to explain how hex, binary and decimal correlates. I recommend that you buy a book that expalins the basics of "microcontrolling". Can't give you any advice on good books since i haven't needed one for 20 years.
Good luck
/Ingvar
Hi,
Haven't followed this from the beginning but I'll jump in here real quick.
A word is 16bits. A byte is 8bits. A word consists of 2bytes a high and a low. To combine 2 bytes into a word you can do:
If Result_h is 100 in decimal and Result_l is 25 in decimal. Your result would be 25625 in decimal. Or if you like in binary.Code:MyWordResult var WORD MyWordResult = Result_h * 256 + Result_l HSEROUT [#MyWordResult,10]
See? The high byte is 100 and the low byte is 25.Code:H I G H L O W B Y T E B Y T E MSB---> 01100100 00011001 <----LSB
Since the most significant bit in the low byte equals to 128 the least significant bit in the high byte equals to 256. That is why you multiply the highbyte by 256.
Or seeing it as 16bit word:
LSB MSB
1+0+0+8+16+0+0+0+0+0+1024+0+0+8192+16384+0 = 25625
/Henrik Olsson.
Last edited by HenrikOlsson; - 3rd October 2006 at 13:08.
Bookmarks