Pages: [1]   Go Down
Author Topic: PROGMEM 4Byte Werte zurücklesen -Fehler beim kompalieren  (Read 260 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo zusammen,

kann mir jemand einen Tipp geben, warum das zurücklesen eines Wertes aus dem Array via PROGMEM beim kompalieren
nicht funktioniert und mir den Fehler 'anArray' was not declared in this scope zurückmeldet?

Code:
#include <avr/pgmspace.h>

void setup() {
  Serial.begin(115200); // Serielle Kommunkation mit 115200 bps initialisieren

  const long anArray[] PROGMEM = { 6854760,3427380,2284920,1713690,1370952,1142460,979251,856845,761640,685476,623160,571230,527289,489626,456984,428423,403221,380820,360777
        ,342738,326417,311580,298033,285615,274190,263645,253880,244813,236371,228492,221121,214211,207720,201611,195850
        ,190410,185264,180388,175763,171369,167189,163209,159413,155790,152328,149017,145846,142808,139893,137095,134407
        ,131822,129335,126940,124632,122406,120259,118186,116182,114246,112373,110561,108806,107106,105458,103860,102310
        ,100805,99344,97925,96546,95205,93901,92632,91397,90194,89023,87882,86769,85685,84627,83595,82587,81604,80644
        ,79707,78790,77895,77020,76164,75327,74508,73707,72923,72155,71404,70668,69947,69240,68548,67869,67204,66551
        ,65911,65283,64668,64063,63470,62888,62316,61755,61203,60662,60129,59607,59093,58588,58091,57603,57123,56651
        ,56187,55730,55280,54838,54403,53974,53553,53138,52729,52326,51930,51540,51155,50776,50403,50035,49672,49315
        ,48963,48615,48273,47935,47603,47274,46950,46631,46316,46005,45698,45396,45097,44802,44511,44224,43941,43661
        ,43385,43112,42842,42576,42313,42054,41797,41544,41294,41046,40802,40561,40322,40086,39853,39623,39395,39170
        ,38948,38727,38510,38295,38082,37872,37664,37458,37254,37053,36854,36656,36461,36269,36078,35889,35702,35517
        ,35334,35153,34973,34796,34620,34446,34274,34103,33934,33767,33602,33438,33276,33115,32956,32798,32642,32487
        ,32334,32182,32032,31883,31735,31589,31444,31300,31158,31017,30877,30739,30602,30466,30331,30197,30065,29933
        ,29803,29674,29546,29420,29294,29169,29046,28923,28802,28681,28562,28443,28325,28209,28093,27979,27865,27752
        ,27640,27529,27419,27310,27201,27094,26987,26881
  };
 
}

void loop(void) {

              // read back a 4-byte
              long displayInt = (long) pgm_read_dword (&anArray[1]);
               Serial.println("---------------------------------");
               Serial.println(displayInt);


}

 Gruß
 Snoops
Logged

Germany
Online Online
Edison Member
*
Karma: 46
Posts: 2310
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Dein Array existiert nur in der setup-Routine, nicht global.
Logged

Mein Arduino-Blog: http://www.sth77.de/ - letzte Einträge: Teensy 3.0 - Teensyduino unter Window 7 - Teensyduino unter Windows 8

Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahhh, alles kar!
Kaum macht mans richtig gehts auch...
 smiley-mr-green
Logged

Pages: [1]   Go Up
Jump to: