Loading...
Pages: [1]   Go Down
Author Topic: Warning in Tone.cpp  (Read 1189 times)
0 Members and 1 Guest are viewing this topic.
Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In Arduino v1.0 all warnings are turned on by default. Tone.cpp generates a warning:

arduino-1.0\hardware\arduino\cores\arduino\Tone.cpp:93: warning: only initialized variables can be placed into program memory area

This can be fixed by changing Tone.cpp

from this:

Code:
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "pins_arduino.h"

#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)

to this:

Code:
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "pins_arduino.h"

// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__((section(".progmem.data")))
#endif

#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)

Hope that helps anyone else who is also frustrated when red text rushes by in the IDE.

Iain
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 108
Posts: 6607
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Odd that the message shows up.  The variable being put into PROGMEM is initialized:

Code:
/*88*/ // MLS: This does not make sense, the 3 options are the same
/*89*/ #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
/*90*/
/*91*/ #define AVAILABLE_TONE_PINS 1
/*92*/
/*93*/ const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
/*94*/ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
/*95*/
/*96*/ #elif defined(__AVR_ATmega8__)
/*97*/
/*98*/ #define AVAILABLE_TONE_PINS 1
/*99*/
Logged

Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed. But at least this makes it go away.

Iain
Logged

Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 27
Posts: 1656
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Odd that the message shows up.  The variable being put into PROGMEM is initialized:

It depends on what "initialized" means. If it means initialized data, i.e. data that is copied from
flash to RAM during startup to "initialize" the variable, then no, it is not an initialized data variable.

My question, is if you do this, does it break the linker optimization, -fdata-sections so that
unused progem data will now end up in flash.
It should be easy to run a test to see.

--- bill
Logged

Pages: [1]   Go Up
Print
 
Jump to: