Forum: Mikrocontroller und Digitale Elektronik Variablen mit IAR im Flash ablegen


von LtData (Gast)


Lesenswert?

Hi,

da ich mein CAN-Bus Problem nicht lösen konnte, probiere ich jetzt 
einfach mal einen anderen Compiler: IAR

Nur wie speichert man da Zeichenketten im Flash?

mitm GCC ging das so

PGM_P Zeile1[] = "hello world!";

mit IAR geht das so auf jeden Fall nicht mehr (compiler meckert).

Bei IAR steht in der cavr.pdf auf Seite 72 (Zitat):

"The AVR IAR C/EC++ Compiler normally copies strings from flash to data 
memory before main() is called, or lets you place them in external ROM 
(if available). Other string literals can be placed explicitly in flash, 
for example like this:
__flash char str1[] = "my string";"

bringt bei mir aber beim compilieren nur den Fehler:
"memory attributes are not allowed on auto variables or parameters"
Also wie mach ichs richtig?

von Jens Gerdes (Gast)


Lesenswert?

Hallo, die Fehlermeldung kommt dann, wenn Du eine lokale Variable mit 
__flash deklarierst. Aber das macht ja sowieso keinen Sinn. Probier es 
mal mit einer globalen Variablen.

Gruss Jens

von LtData (Gast)


Lesenswert?

okay danke. geht jetzt :-) Die Lösung liegt manchmal so nahe...

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.