Author Topic: Rom Address with Microchip MPLABX and XC8  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

Offline PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Rom Address with Microchip MPLABX and XC8
« on: April 14, 2020, 10:27:50 am »
I have updated MPLABX from version 4 to version 5 maintaining the compiler XC8 with version 2.1

Before update, this code worked:

Code: (c) [Select]
#define SAF_ADDRESS              0x3F80   // Storage Area Flash address
const unsigned long PPB_CALIBRATION @ SAF_ADDRESS = 248444;

And now the compiler raise an error:
Code: [Select]
./calibration.h:11:36: error: expected ';' after top level declarator
const unsigned long PPB_CALIBRATION @ SAF_ADDRESS = 248444;
                                   ^
                                   ;

how can i make it work now?

Regards.
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • Very dangerous - may attack at any time
Re: Rom Address with Microchip MPLABX and XC8
« Reply #1 on: April 14, 2020, 12:24:39 pm »
Use __at(address)

Section 2.5.2.3 of MPLAB_XC8_C_Compiler_Legacy_User_Guide.pdf
 

Offline PicuinoTopic starter

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Re: Rom Address with Microchip MPLABX and XC8
« Reply #2 on: April 14, 2020, 01:11:04 pm »
Thanks a lot.
 

Offline 741

  • Frequent Contributor
  • **
  • Posts: 386
  • Country: gb
    • Circuit & PCB Design (small PCB quantities OK)
Re: Rom Address with Microchip MPLABX and XC8
« Reply #3 on: November 19, 2020, 04:32:04 pm »
I have spent nearly a day tracing this in a 2017 project. The @ symbol occurs in the usb framework code from around that time (in file usb_hal_pic16f1.h).

The section referred to is entitled
MIGRATION TO THE CCI

Also, the document MPLAB_XC8_C_Compiler_User_Guide_for_PIC.pdf, 50002737C-page 567 says this

(2036) use of @ is not compliant with CCI, use __at() instead (Parser)
The CCI does not permit the definition of absolute functions and objects that use the @ address construct. Instead,
place __at(address) after the identifier in the definition.
int foobar @ 0x100; // oops -- use __at(0x100) instead



But my project does not have the "Use CCI Syntax" checkbox checked... So why the error?
XC8 v2.20


Update: I found this post on the Microchip forum (https://www.microchip.com/forums/m1058706.aspx), it seems the errors also relate to C99 mode being the new default (but only since XC8 v2.00).
Whole can of worms... :horse: |O

(It is interesting that C99 only now makes it to default in 2020! )
« Last Edit: November 19, 2020, 04:49:44 pm by 741 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf