Could it not be as simple as:-
COUNTER VAR WORD
COUNTER_H VAR COUNTER.BYTE1 'high byte
COUNTER_L VAR COUNTER.BYTE0 'low byte
LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.
Tim.
Could it not be as simple as:-
COUNTER VAR WORD
COUNTER_H VAR COUNTER.BYTE1 'high byte
COUNTER_L VAR COUNTER.BYTE0 'low byte
LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.
Tim.
I don't think so, because although the LCDOUT is very simple and elegant, the maximum number which can be stored in either Counter_H or Counter_L is 255. Therefore the largest value which the word sized variable Counter can be is 255255.
There needs to be a conversion first. The high byte needs to be multiplied by 256 (not 255 as I originally pointed out) and then added to the low byte before it gets stored in the word 'Counter'
Indeed you are right.
Without knowing the exact task, I just wanted to keep it simple...
I need to be able to count to around 2000 without rolling over so 2 bytes would be plenty. I tried the code you posted.. but it still rolled over at 255. hmmm....
It still rolls at 255 ? Did yoiu declare the destination variable as a word or a byte ?
Ever count of 1 of the lower byte equates to 1 in the destination variable, and every count of 1 in the high byte equates to 256 in the destination variable.
2000, in this scheme, consists of highbyte = 7, low byte = 208
As you can see, you need to multiply whatever is in the highbyte by 256. In this case 256*7 = 1792. Then add the lowbyte directly, and 1792 + 208 = 2000
Last edited by Acetronics2; - 10th March 2009 at 09:06.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks