|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
problematic array |
Posted: Fri Jun 25, 2004 4:11 pm |
|
|
I have a question on how to increment an array.
First the important stuff:
PCM 3.148
12F629
I have an array which I initialise thus:
Code: |
// all variables are global \\
//numbers
#define ZERO 0x7E
#define ONE 0x0C
#define TWO 0xB6
#define THREE 0x9E
#define FOUR 0xCC
#define FIVE 0xDA
#define SIX 0xFA
#define SEVEN 0x0E
#define EIGHT 0xFE
#define NINE 0xDE
//LCD display
int digits[10] = {ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE};
int digit_counter = 0; //used to keep track of displayed digit
int bit_counter = 0; //used to keep track of bits within each digit
|
It is used in the main loop
Code: |
while (TRUE)
{
//cycle through digits 0 -> 9
for (; digit_counter <=9; digit_counter++)
{
//increment array
digits[digit_counter];
//set clock low
output_low(S_CLK);
//clock bits out from the array element
for (; bit_counter <=7; bit_counter++)
{
output_bit(S_DATA,shift_right(digits,1,0));
//clock bit out
output_high(S_CLK);
delay_cycles(1);
output_low(S_CLK);
}
//reset bit_counter
if (8 == bit_counter)
{
bit_counter = 0;
}
}
}
|
What I am trying to achieve, is to clock each element of the array serially out through a port pin. It will work the first time as 'digit_counter' is initialised at 0, and I can see the code running as I expect it to via the simulator. However I cannot get the next element of the array to load. I was hoping to use 'bit_counter' to index the elements of the array?
The code compiles and when I run it through the simulator it steps over the line.... digits[digit_counter]; which I hoped was going to increment the array?
Looking at the .lst there is no code shown for this line?
Its getting late and I've probably done something silly - its just that I cant see it. All suggestions gratefully received. |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
|
Posted: Fri Jun 25, 2004 4:14 pm |
|
|
Err I don't know what happened here?
Sorry for the duplication |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|