Hi,
das PROGMEM bringt mich noch um, alles was früher mal geklappt hat macht jetzt Schwirigkeiten.
Offensichtlich habe ich Probleme mit Pointern in den Progmem Bereich.Code:#include <avr/io.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "uart.h" // Peter Fleury #ifndef __ATTR_PROGMEM__ #define __ATTR_PROGMEM__ __attribute__((__progmem__)) #endif #ifndef PROGMEM #define PROGMEM __ATTR_PROGMEM__ #endif S8 sTx[16]; typedef struct PROGMEM Norm { prog_U8 faktor; prog_U8 decimal; const prog_S8 sNormUnit[NORM_UNIT_MAXLEN]; const prog_S8 sNormName[NORM_NAME_MAXLEN]; }norm_t; /*** ---- Normalization ------------- Faktor Decimal Unit Name ------ ***/ norm_t Norm_Voltage1 = { 1, 0, {"V"}, {"VOLTAGE 1"} }; norm_t Norm_Voltage2 = { 1, 3, {"mV"}, {"VOLTAGE 2"} }; norm_t* PROGMEM NormArray[] = { (norm_t*)&Norm_Voltage1, (norm_t*)&Norm_Voltage2 }; void foo(void) { norm_t* p_norm; p_norm = (norm_t*) NormArray[0]; uart_puts( (S8*) p_norm->sNormName ); // Da kommt nur mist raus uart_puts( (S8*) ((norm_t*)NormArray[0])->sNormName ); // Da auch }
Und das nicht nur bei Strings sondern auch Werte kommen falsch raus.
mit den Pointern tu ich mir einfach schwer.Code:void foo(void) { uart_puts( itoa( NormArray[i]->factor, sTx, 10) ); }
Weiß hier jemand weiter?
Oder kennt einer ein Beispiel für Constanten und deren Benutzung im PROGMEM bereich?
gruß christoph







Zitieren
Lesezeichen