I was trying to display 7-segment LED on MDA-8086 kit, but I am stuck at calculating the hexadecimal values for respective digits. I have the code with me, but I don't understand how it actually works. For example, 0 is represented by hexadecimal value 0xc0 [I guess]. I am wondering, how the values have been calculated here?
C Code for 7-segment LED display:
#include"mde8086.h"
int data[11] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x00 };
void wait(long del)
{
while( del-- );
}
void main(void)
{
int *data1;
/* 8255 -1 Initialization */
outportb( PPI1_CR, 0x80 );
outportb( PPI1_B, 0xf0 );
outportb( PPI1_C, 0x00 );
//main loop
do {
data1 = data;
while( *data1 != 0x00 )
{
outportb( PPI1_A, *data1 );
wait(30000);
data1++;
}
} while(1);
}
The output has been generated from here:
1
is displayed by lighting only 2 segments total, so we can tell that must be0xc0
(which only has 2 bits set in its binary representation, so segment b = 0x80, c = 0x40 or vice versa).So looping over this array counts up from 1 to 9 then wraps to 0, I guess. But that doesn't work if you look at the rest; there are other patterns with only 1 or a couple bits set, so it must be that the masks are inverted, and clear bits light up the corresponding segment? Then leaving segment G and the decimal-point unlit could be the top 2 bits. – Rambunctious