Brian Hoskins
New Member
Hi there all,
I've presented myself with what I believe to be a small problem but at the moment I'm banging my head against the desk trying to come up with a good method of solving it.
Basically, I have 10 LED displays that I want to select from within my C program. Only 1 display will be selected at a time (I'm multiplexing them). I've done this before with 4 LED displays and to do it I created an array as follows;
const char select [4] = {1, 2, 4, 8} ;
And then when I wanted to select one of the four displays I just wrote something like;
PORTA = select[*insert display number here*]
And then PORTA would output the required bit pattern to enable the intended display. That all works fine. Here's my problem;
I now want to select from 10 displays instead, using the same idea. But that required more than 8 bits so it's larger than PORT A!
To remedy this I want to use all 8 bits of PORT A, and also two bits from PORT E to make a 10 bit port. I want to define this somehow, so that I can say something like
SELECTPORT = select[*insert display number here*]
where SELECTPORT refers to all of PORTA and also the required two bits of PORTE.
And this is the basis of my question - how do I go about defining this? I'm racking my brains and I can't think how but I'm certain there's going to be an easy way of doing it.
Suggestions?
Cheers!
Brian
I've presented myself with what I believe to be a small problem but at the moment I'm banging my head against the desk trying to come up with a good method of solving it.
Basically, I have 10 LED displays that I want to select from within my C program. Only 1 display will be selected at a time (I'm multiplexing them). I've done this before with 4 LED displays and to do it I created an array as follows;
const char select [4] = {1, 2, 4, 8} ;
And then when I wanted to select one of the four displays I just wrote something like;
PORTA = select[*insert display number here*]
And then PORTA would output the required bit pattern to enable the intended display. That all works fine. Here's my problem;
I now want to select from 10 displays instead, using the same idea. But that required more than 8 bits so it's larger than PORT A!
To remedy this I want to use all 8 bits of PORT A, and also two bits from PORT E to make a 10 bit port. I want to define this somehow, so that I can say something like
SELECTPORT = select[*insert display number here*]
where SELECTPORT refers to all of PORTA and also the required two bits of PORTE.
And this is the basis of my question - how do I go about defining this? I'm racking my brains and I can't think how but I'm certain there's going to be an easy way of doing it.
Suggestions?
Cheers!
Brian