What I would do is:
Code:
PORTC = PORTC & %11100000 / Clear all the bits in PORTC that are segments
PORTC = AVAL[x] | PORTC / sets the bits in PORTC that are '1' in AVAL[x]
PORTA = PORTA & %11111001 / Clear all the bits in PORTA that are segments
PORTA = CVAL[x] | PORTA / sets the bits in PORTA that are '1' in CVAL[x]
if you just want to use one matrix for segment data you can do this:
Code:
ORMASK = SEGVAL[x] & %00011111 / makes sure only 5 lsb of SEGVAL[x] '1' bits get set below
PORTC = PORTC & %11100000 / Clear all the bits in PORTC that are segments
PORTC = ORMASK | PORTC / sets the bits in PORTC that are '1' in AVAL[x]
ORMASK = SEGVAL[x] >> 4 / shift data 4 to right to position correct SEGVAL[x] bits for PORTA
ORMASK = ORMASK & %0000110 / makes sure only 2 bits of SEGVAL[x] '1' bits get set below
PORTA = PORTA | %11111001 / Clear all the bits in PORTA that are segments
PORTA = ORMASK | PORTA / sets the bits in PORTC that are '1' in AVAL[x]
Bookmarks