Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

7 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 &#39;led_value |= (_hex_digits_data[(value >> 4) & 0xF]) << 8;&#39; n change the value to 10, it print 60.

anyone has any idea wat&#39;s wrong? pls advise. thx.