Replacing Huge Pointer in C

84 Views Asked by At

I am currently working on a project where I need to replace the existing microcontroller, which belongs to the M16C family, with a new microcontroller from the RX family. In the old code for the M16C microcontroller, I have the following memory qualifier defined:

#define CHIPDATA huge

extern byte CHIPDATA Mode4Reg[1];

My goal is to transition to the RX family while retaining the use of the CHIPDATA attribute. However, the "huge" memory qualifier is not directly applicable to the RX family, and I need to adapt it for the new environment.

Could you please provide guidance on how to replace the "huge" memory qualifier with an appropriate equivalent for the RX family microcontroller? I want to preserve the use of CHIPDATA in the code.

I have tried the following but it doesn't work:

#pragma section = "MyExternalMemorySection"

#define CHIPDATA __root
1

There are 1 best solutions below

0
On

M16C has different memory models for 13, 16 and 20 bit addressing. RX is a 32 bit Harvard Architecture MCU and the same memory models do not apply. You most likely need to do nothing special for RX addresses and can simply define an empty macro:

#define CHIPDATA

If you want to be able to build the same codebase cross platform then:

#if defined __M16C__
    #define CHIPDATA huge
#else
    #define CHIPDATA
#endif

However it seems that you are in fact trying to use the CHIPDATA modifier for a different purpose on the new platform, making this an X-Y problem. Ask a new question about how to define a macro to locate specific data to a linker section (if that is what you are trying to do). You can then call that macro CHIPDATA should you choose for re-usability of existing code. The means will necessarily be toolchain specific, so you need to specify. Whether such a macro would be valid as a prefix to the declaration rather then a suffix may be an issue. It may not be possible to achieve what you want, but until it is clear what it is you do want, it is hard to tell.