beech01
Tester
Reged: Apr 11 2008
Posts: 2
|
|
I'm just starting in on trying to use the Hi-tech compiler with a proven project, and have made it past a number of issues. Now I'm stuck with pointers. Examples of warnings are: (1) main.c: nvm_erase() 1557: p_nv_mem = 0x3A00; ^(357) illegal conversion of integer to pointer (warning)
where the pointer is defined as:
volatile unsigned char xdata * p_nv_mem; //Pointer to write to FLASH
(2) main.c: main() 238: usb_send_message(STARTUP); ^(359) illegal conversion between pointer types (warning)
where applicable lines of code are:
const BYTE code STARTUP[] = {0x1C,'T',CR,LF,'N','V','E',':',' ','U','S','B',' ', '3','D','-','M','a','g','n','e','t','o','m','e','t', 'e','r',NULL};
void usb_send_message(unsigned char * usb_message);
Any thoughts on how to fix this so I can discover what the next problem will be?
PS - the Hi-tech license expires today. Will you be extending the eval/offer period any? Or should I just drop it?
|
mikerj
Guru
  
Reged: Oct 19 2003
Posts: 1279
Loc: Devon, UK
|
|
Quote:
I'm just starting in on trying to use the Hi-tech compiler with a proven project, and have made it past a number of issues. Now I'm stuck with pointers. Examples of warnings are: (1) main.c: nvm_erase() 1557: p_nv_mem = 0x3A00; ^(357) illegal conversion of integer to pointer (warning)
where the pointer is defined as:
volatile unsigned char xdata * p_nv_mem; //Pointer to write to FLASH
The clue is in the warning: 0x3A00 is a simple integer value, which you are assigning to a pointer, so they are of different types. In this instance you should be able to remove the warning by casting the integer to the desired pointer type:
Code:
p_nv_mem = (volatile unsigned char xdata *)0x3A00;
Quote:
(2) main.c: main() 238: usb_send_message(STARTUP); ^(359) illegal conversion between pointer types (warning)
where applicable lines of code are:
const BYTE code STARTUP[] = {0x1C,'T',CR,LF,'N','V','E',':',' ','U','S','B',' ', '3','D','-','M','a','g','n','e','t','o','m','e','t', 'e','r',NULL};
void usb_send_message(unsigned char * usb_message);
Your array and the declared function parameter are of different types, one is qualified const, the other is not. There is also a "code" qualifier which I'm not familliar with being more of a PIC user. In general your function parameter must match the type of data you pass to the function exactly. If not you may be able to cast it (though this can cause unexpected results) or you may have to write an alternative function for specific data types.
|
beech01
Tester
Reged: Apr 11 2008
Posts: 2
|
|
Thanks for the reply.
Let's concentrate on (1) for now. This seems odd to me since a pointer is an integer (it is an address), and I've never had trouble before in assigning a literal value to a pointer. Anyway, I tried your suggestion of casting the literal 0x3A00:
p_nv_mem = (volatile unsigned char xdata *)0x3A00;
and the error message remained the same. Any new thoughts?
As an aside, I am using this pointer to xdata in order to get the compiler to generate the correct code (MOVX and MOVC) for reading and writing FLASH (i.e. code) memory - this is how it works with one of your competitor's product. I don't see any mention in the user manual about accessing FLASH with Hi-Tech. Is this the way to do it? Or is there another technique that you require in order to target FLASH for read and write?
|
|