BS1 newbie questions
JackPollack
Posts: 8
Hi, am a newbie and have several BS1 questions:
1. I am using· lookup to build a table of binary coded decimal data
eg:
27 Really represents 010 (binary 2) and 111 (binary 7)
54 Really represents 101 (binary 5) and·010 (binary 4)
If b0 is my BDC number (54)
I am unsing· b0/10//10·to get digit 1 and· b0//10 to get digit 2
How can I output to 3 specific bits based on my decimal number without effecting the other bits?
2. I screwed up on the bit order. I used ABCD... instad of ...DCBA. So if there is a simple answer to question 1 (I am thinking some type of bit mask, but don't really know how to create it) I think that the numbers I output are going to need to be flipped.
Sorry if this is hard to understand, but I am REALLY CONFUSED.
Thanks for your help
1. I am using· lookup to build a table of binary coded decimal data
eg:
27 Really represents 010 (binary 2) and 111 (binary 7)
54 Really represents 101 (binary 5) and·010 (binary 4)
If b0 is my BDC number (54)
I am unsing· b0/10//10·to get digit 1 and· b0//10 to get digit 2
How can I output to 3 specific bits based on my decimal number without effecting the other bits?
2. I screwed up on the bit order. I used ABCD... instad of ...DCBA. So if there is a simple answer to question 1 (I am thinking some type of bit mask, but don't really know how to create it) I think that the numbers I output are going to need to be flipped.
Sorry if this is hard to understand, but I am REALLY CONFUSED.
Thanks for your help
Comments
eg
00 111 111
unused bits Digit 1 Digit2
But remember for me the unused bits are pin 6 & 7
How do you want to do your output? If, for example you were going to use P0-P3 for the one's digit, and P4-P7 for the ten's digit, you could do this:
Pins = decVal / 10 * 16
Pins = decVal // 10 | Pins
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
>How do you want to do your output?
I want bits 5,4,3 to be digit 1 (remember bit 5 is my 1 bit)
I want bits 2,1,0 to be digit 2 (2 is my 1 bit for this pair)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Thanks, and have a nice holiday.