pak:
Hello dude,
I'm testing Mighty 1284p 16MHz Optiboot with Arduino IDE v1.0. when you upload the following sketch, what is the maximum value of "arraysize" while led blinking?
#include <avr/pgmspace.h> //To store arrays into flash rather then SRAM
// Simple sketch to create large sketch sizes for testing purposes
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
/*
Make arraysize = to 1500 for 328P chip, 4000 for 1280P chip?,
3600 for 644P chip, xxxx for 1284P, etc.
*/
const int arraysize= 7700; // value to mostly fill avalible flash capacity
long myInts0[arraysize] PROGMEM = {}; //Store initilized array into flash memory
long myInts1[arraysize] PROGMEM = {};
long myInts2[arraysize] PROGMEM = {};
long myInts3[arraysize] PROGMEM = {};
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
int i = random(0,arraysize); // Work around any optimization for constant values
Serial.print(myInts0[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts1[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts2[i]); // Access some random element so the array can't be optimized away.
Serial.print(myInts3[i]); // Access some random element so the array can't be optimized away.
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
And 'avrsize' is showing the usage...
AVR Memory Usage
Device: atmega1284p
Program: 127366 bytes (97.2% Full)
(.text + .data + .bootloader)
Data: 427 bytes (2.6% Full)
(.data + .bss + .noinit)
I can upload sketch size 127k (arraysize=7700) without error, but led is not blinking. :D
When I change the value of "arraysize" = 4070 (69k byte), led is blinking. It's too bad. :( Any idea?
Regards,
pak
This was reported on extensively in a prior posting thread sometime last year. I believe the root problem ended up being a compiler thingee with the PROGMEM command. You can have code up to the full flash size of the 1284 chip but data sizes using PROGMEN doesn't work over the 64KB boundary. At least that is the best of my recollection on the subject.
Lefty