Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
NOTE: I am reposting this question to include the code I was talking about.
I am working with the Arduino code at this link and I copied and pasted the code at the bottom of this writing.

I need to setup a microcontroller for displaying 8-bit binary as decimal. I am not concerned about signed numbers. I just need to display binary representation of 0 to 255 as a decimal numbers.
I followed a tutorial and I used a CAT28C16 EEPROM and I wrote bytes to it using the mentioned code. Although I would like to learn a lot about microcontrollers data organization to analyze my problem myself, I have to to urgently make the hardware ready for use. For this reason, I would appreciate any information that could help me to realize why I get wrong output.
With my limited knowledge about the code, I suspect the contents of the digits array is not as it should be. According to the author of the code, the digits array holds hex codes that are used to display the binary as decimal. That sounds to me like hex representation of of BCD but it does not seem that the digits array holds such hex numbers.
The digits array is supposed to hold the Bit patterns for the digits 0..9 according to the tutor programming comment. Do you see any problem with the digits array? If not, do you have any idea what can be wrong?

Because I cannot add a snapshot of the author's EEPROM contents, I just write the first two rows of the content which the tutor produced in his video:

000: 7e 30 6d 79 7e 30 6d 79 7f 7b 7e 30 6d 79 33 5b
010: 5f 70 7f 7b 7e 30 6d 79 33 5b 5f 70 7f 7b 7e 30

Here is the content of my EEPROM from address 000 to 0f0:
000:  33 5b 5f 70 33 5b 5f 70   6d 7 33 5b 6d 79 33 5b
010:  7e 30 6d 79 7e 30 6d 79  7f 7b 7e 30 7f 7b 7e 30
020:  5f 70 7f 7b 5f 70 7f 7b   33 5b 5f 70 33 5b 5f 70
030:  6d 79 33 5b 6d 79 33 5b   7e 30 6 79 7e 30 6d 79
040:  7f 7b 7e 30 7f 7b e30   5f 70 7f 7b 5f 70 7f 7b
050:  33 5b 5f 7 33 5b 5f 70  6 79 33 5b 6d 79 33 5b
060:  7e 30 6d79 7e 30 6d 79   7f 7b 7e 3 7f 7b 7e 30
070:  5f 70 7f 7b 5f 70 7f 7b   33 5b 5f 70 33 5b 5f70
080:  6d 79 33 5b 6d 79 33 5b   7e 30 6d 79 7e 30 6d 79
090:  7f 7b 7e 30 7f 7b 7e 30   5f 70 7f 7b 5f 0 7f 7b
0a0:  33 5b 5f 70 33 5b 5f 70   6d 79 33 5b 6d 79 33 5b
0b0:  7e 30 6d 79 7e 30 6d 79   7f 7b 7e 30 7f 7b 7e 30
0c0:  5f 70 7f 7b5f 70 7f 7b   33 5b 5f 7033 5b 5f 70
0d0:  6d 79 33 5b 6d 79 33 5b  e 30 6d 79 7e 30 6d 79
0e0:  7f 7b 7e 30 7f 7b 7e 30   5f 70 7f 7b 5f 70 7f 7b
0f0:  33 5b 5f 70 33 5b 5f 70   6d 79 33 5b 6d 79 33 5b

As you can see from the pattern in the contents of my EEPROM, it starts with wrong line. On each line, the first 4 bytes are repeated as bytes 5 to 8 while they should be the bytes 5 to 8 of previous line. This should be corrected so that the contents of my EEPROM to look like the snapshot from the tutors video.

And here is examples of base(2) displayed in base(10):
0(2)—>4(10),   1(2)—>5(10),   2(2)—>8(10),   3(2) —>8(10),   
4(2)—>136(10),   5(2)—>137(10),        6(2)—>6(10),   7(2)—>7(10), 
8(2)—>12(10),   9(2)—>13(10),   10(2)—>18(10),   11(2)—>88(10), 
12(2)—>144(10),   13(2)—>145(10),   14(2)—>14(10), 15(2)—>15(10). 

For numbers > 15, the decimal number is 4 more than what it should be.

What I have tried:

I tried to modify the loop indexes but did not help to produce the right result. I suspect the digits array content in the code but I do not have a good understanding to modify it.
Posted
Updated 21-Mar-22 10:17am
v4
Comments
jeron1 21-Mar-22 16:35pm    
I don't see any code. What do you want to display and where do you want to display it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900