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

do while timeout?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 07, 2005 11:56 am     Reply with quote

I think most of your problems are caused by a mis-understanding
of data types and sizes.

The read_ext_eeprom() function only returns an 8-bit unsigned value.
You are expecting that it returns a 16 bit value. This is apparent
because you compare 'data' to 0x101. But look at the function
definition in your EEPROM driver file. The return value is a 'BYTE',
which is 8 bits. A byte value can only range from 0x00 to 0xFF, and
can never be equal to 0x101.

Also, you should know that in CCS, an 'int' is an 8-bit unsigned value.
It's the same as 'BYTE'.

BYTE read_ext_eeprom(long int address)
{
}

data = read_ext_eeprom (DATA_BLOCK_SIZE + (mem_pointer * 256));
mem_pointer++; '
if ( data == 0x101 )
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Sat Oct 08, 2005 5:24 am     Reply with quote

PCM programmer wrote:
I think most of your problems are caused by a mis-understanding
of data types and sizes.

The read_ext_eeprom() function only returns an 8-bit unsigned value.
You are expecting that it returns a 16 bit value. This is apparent
because you compare 'data' to 0x101. But look at the function
definition in your EEPROM driver file. The return value is a 'BYTE',
which is 8 bits. A byte value can only range from 0x00 to 0xFF, and
can never be equal to 0x101.

Also, you should know that in CCS, an 'int' is an 8-bit unsigned value.
It's the same as 'BYTE'.

BYTE read_ext_eeprom(long int address)
{
}

data = read_ext_eeprom (DATA_BLOCK_SIZE + (mem_pointer * 256));
mem_pointer++; '
if ( data == 0x101 )



Yes, admittedly the data test if (data == 0x101) is an error. I originally wrote the code for a 10-bit adc conversion but got the code around my neck a bit. This is a bit of legacy code from that. I thought i'd keep it simple this time by just having an 8-bit adc value to begin with, and get that working first. I'm still learning you know!


Quote:

Also, you should know that in CCS, an 'int' is an 8-bit unsigned value.
It's the same as 'BYTE'.


Ok, thanks for that.

So, where to go from here. Do I scrap the do/while loop. Go back to the for loop I had before and count the number of 'B' chars received or use receive interrupts? Please help as I'm a bit stuck!

Many thanks for your comments,
Ed
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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