chipKIT® Development Platform

Inspired by Arduino™

Using F() in MPIDE?

Created Wed, 04 Dec 2013 20:49:49 +0000 by snugRugBug


snugRugBug

Wed, 04 Dec 2013 20:49:49 +0000

Hi all

I'm used to working in the Arduino Environment, but I liked the idea of MPIDE, so I'm trying it out. I'm currently working with a Seeeduino Stalker, and it uses an ATmega328.

When using Arduino IDE, I would put all my "constant" strings inside F() in order to save on RAM usage:

Serial.print(F("This string is stored in the flash memory"));

This places the string data in the flash memory, thus saving some RAM. This all works well in Arduino IDE, but when I copy some code to MPIDE, the F() notation isn't recognised at all. The error reads:

"sketch_dec04a:30: error: 'F' was not declared in this scope"

Is there a way to make MPIDE support F()? Am I missing something crucial/obvious?

Thank you all


majenko

Thu, 05 Dec 2013 10:34:46 +0000

#define F(X) (X)

The F() macro is pointless in the PIC32 as it's only needed for Harvard architecture systems, which the PIC32 isn't. In a Harvard architecture system the "const" strings are copied to RAM for ease of access. That's not needed on a Priceton system where the flash and the RAM share the same memory space.