 |
 |
| View previous topic :: View next topic |
| Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 07, 2005 11:56 am |
|
|
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
|
|
Posted: Sat Oct 08, 2005 5:24 am |
|
|
| 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 |
|
 |
|
|
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
|