Search code examples
ciar8051

Don't understand conversion from integer to smaller pointer error


I am working on an 8051 platform which has a 16 bit pointer width.

I have a common code module for handling flash emulation and there's a function that returns the 16 bit start address of a page:

volatile u16_t start_address = find_start_address_of_page( page );

I think want to pass this 'address' to a CRC function that wants a u8_t* as a parameter so I cast it in the function call like so:

(u8_t *)start_address

This generates the warning

Warning[Pe1053]: conversion from integer to smaller pointer

Which confuses me a bit, because a u8_t* is 16 bits wide, and my variable is a 16 bit variable.. Is it simply that the compiler is warning about an "integer to pointer" conversion in general?

The code works fine, I just want to be sure I'm not missing something silly here...


Solution

  • You write that your 8051 platform has a 16 bit pointer width.

    As far as I know, the 8051 has different address ranges for - the internal RAM in the processor (max 256 Byte) - external RAM (max 64k) - Program Memory (max 64k)

    The compiler I have worked with (Keil) therefore had at least four different pointer types. An 8 bit wide 'data' pointer for the internal RAM. A 16 bit wide 'xdata' pointer for the external RAM. A 16 bit wide 'code' pointer for the Program Memory. A 24 bit wide universal pointer which could be set to point to any of the three memory types. The first byte was used to select the memory type.

    The warning text could mean that the compiler wants to convert your 16 bit value to an address in internal RAM which is only 8 bits wide.