View previous topic :: View next topic |
Author |
Message |
cwf713
Joined: 10 Sep 2003 Posts: 4
|
Invalid type conversion? |
Posted: Mon Sep 12, 2005 9:04 am |
|
|
I am upgrading an existing design from a 16F877 to a 18F4525. The following code compiles and works with the 16F877 device. The compiler is PCM ver. 2.660.
My new compiler is PCH ver. 3.225. I get the error message "Invalid type conversion" at the line tmp[i] = read_eeprom(i); Does anyone have any idea why?
Many thanks,
Chris Code: |
void data_startup(void)
{
struct data *tmp;
int magicnuml,magicnumh;
char magicnum[2];
long int i;
short rewrite = 1;
magicnuml = read_eeprom(0);
magicnumh = read_eeprom(1);
magicnum[0] = magicnuml;
magicnum[1] = magicnumh;
if((magicnuml == 0x4A) && (magicnumh == 0x53))
{
rewrite = 0;
tmp = ¤t_data;
for(i = 0;i < data_size;i++)
{
tmp[i] = read_eeprom(i);
}
.
.
.
|
|
|
|
Ttelmah Guest
|
|
Posted: Mon Sep 12, 2005 10:26 am |
|
|
Post the definition of the structure 'data', and the details of what is in the variable 'data_size'.
If 'tmp', is a pointer to a structure, how can the line be valid?...
Best Wishes |
|
|
cwf713
Joined: 10 Sep 2003 Posts: 4
|
|
Posted: Mon Sep 12, 2005 11:13 am |
|
|
Thank you for the reply. Here is the definition of the data structure.
I don't know if it is valid or not to use a pointer to store the results from read_eeprom() but it works with the old PCM compiler for some reason.
Thanks,
Chris
Code: |
#define data_size 17 // the number of bytes of data contained in the struct.
struct data
{
long magicnum;
long up_freq;
long down_freq;
signed long up_gain;
signed long down_gain;
signed long ref_os;
int address;
int inputlvl; //abs of the input level, true value always -10 - -40.
short other;
short mute;
short upinv;
short dninv;
short remote;
short rs485;
short extref;
short up_refout;
short down_refout;
short rs422;
short rs232;
short ref_int;
short ref_ext;
short ref_auto;
short dummy5; //not used for anything, allows us to have an even amount of memory.
short dummy6; //not used for anything, allows us to have an even amount of memory.
int chksum; //data checksum - equal to everything in the struct except this number
// mod 255.
};
struct data current_data;
struct data temp_data; |
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Sep 12, 2005 11:30 am |
|
|
tmp should be of type char or int8 since that is the way that you are accessing it. |
|
|
cwf713
Joined: 10 Sep 2003 Posts: 4
|
|
Posted: Mon Sep 12, 2005 2:45 pm |
|
|
I changed the type def. for the variable *ptr to int and it now compiles.
Thanks for all of the help.
Chris |
|
|
|