CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Counter problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bwgames



Joined: 21 Jul 2005
Posts: 36

View user's profile Send private message

Counter problems
PostPosted: Wed Sep 06, 2006 2:33 am     Reply with quote

I have the below code to read from an EEPROM and output several lines at once (rather than having to read the EEPROM for each line which slows it down), yet I don't get any output apart from:

"j= "


Any ideas?

Code:

int32 i;
int32 j;
int32 number;

char X_array[10];
char Y_array[10];
char Z_array[10];

....
number = 5000; //can change
i=0;
j=0;
do {

while((j<8)&&((i-7)<number))
{
X_array[j] = read_eeprom_byte(framWrite[0],framRead[0],addr+i);
Y_array[j] = read_eeprom_byte(framWrite[1],framRead[1],addr+i);
Z_array[j] = read_eeprom_byte(framWrite[2],framRead[2],addr+i);
j++;
i++;
}//end of if j<8
fprintf(Wireless,"\n\rj= %Lu\n\r",j); //debugging output
j=0;

while((j<8)&&((i-7)<number))
{
fprintf(Wireless,"%Lu,%i,%i,%i\n\r",(i-7),X_array[j],Y_array[j],Z_array[j]);
j++;
}

j=0;
delay_ms(100);
} while((i-7)<number);

treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 06, 2006 8:31 am     Reply with quote

From the help file
Quote:
Note: All types, except float, by default are unsigned

Thus int32 is unsigned.
you never enter while loop because
i=0
i-7=04294967289 //remember i is unsigned so subtraction wraps to a pos number

(i-7)<5000) fails
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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