Altera_Forum
Honored Contributor
19 years ago7 segment display showing wrong values
np_pio *ssd = (np_pio *)na_SEG7_Display;
static unsigned char _hex_digits_data =
{
0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x00, 0x04, // 0-9
0x08, 0x60, 0x72, 0x42, 0x30, 0x38 // a-f
};
void main(void)
{
long x;
np_pio *led;
led = na_led_red;
led->np_piodata = 11;
nr_pio_showhex(11);
}
void nr_pio_showhex(int value)
{
int led_value;
led_value = _hex_digits_data;
led_value |= (_hex_digits_data) << 8;
ssd->np_piodata = led_value;
} when i run the above code in uclinux on DE2, the 7 seg display show 160. when i change the value to 10 instead of 11, it shows 108. den i remove the line 'led_value |= (_hex_digits_data[(value >> 4) & 0xF]) << 8;' n change the value to 10, it print 60. anyone has any idea wat's wrong? pls advise. thx.