Falsche Deklaration in pgmspace.h ?

OP #438516
Lesenswert?

Hi Leute

im Headerfile pgmspace.h ist folgendes deklariert
1
#ifndef __ATTR_CONST__
2
#define __ATTR_CONST__ __attribute__((__const__))
3
#endif
4

5
#ifndef __ATTR_PROGMEM__
6
#define __ATTR_PROGMEM__ __attribute__((__progmem__))
7
#endif
8

9
#ifndef __ATTR_PURE__
10
#define __ATTR_PURE__ __attribute__((__pure__))
11
#endif
12

13
#define PROGMEM __ATTR_PROGMEM__
14

15
typedef void prog_void PROGMEM;
16
typedef char prog_char PROGMEM;
17
typedef unsigned char prog_uchar PROGMEM;
18

19
typedef int8_t    prog_int8_t   PROGMEM;
20
typedef uint8_t   prog_uint8_t  PROGMEM;
21
typedef int16_t   prog_int16_t  PROGMEM;
22
typedef uint16_t  prog_uint16_t PROGMEM;
23
#if !defined(__USING_MINT8)
24
typedef int32_t   prog_int32_t  PROGMEM;
25
typedef uint32_t  prog_uint32_t PROGMEM;
26
#endif
27
typedef int64_t   prog_int64_t  PROGMEM;
28
typedef uint64_t  prog_uint64_t PROGMEM;


Wenn ich nun eine Konstante/Variable als
1
prog_uint_t c1[] = {1,2,3,4};

deklariere, erwarte ich eigentlich das diese Daten im FLASH abgelegt 
werden und ich später mit pgm_read_byte() darauf zugreifen kann.

Die Daten werden aber nicht in .section  .progmem.data,"a",@progbits 
abgelegt sondern in .data

Ein Zugriff mit pgm_read_byte() muß also schweitern.

Ich meine die Deklaration ist falsch denn benutzt man nachfolgendes 
klappt es
1
typedef uint8_t   prog_uint8_t  __attribute__ ((PROGMEM));
2

3
statt eben
4

5
typedef uint8_t   prog_uint8_t PROGMEM;

Liege ich mit meiner Annahme richtig, oder mach ICH was falsch ?

Gruß hagen
Persönliche Seite #438564
Lesenswert?

Hallo Hagen!

Hm, Dein Problem kann ich nicht nachvollziehen.
Folgender Code:
1
#include <avr/io.h>
2
#include <avr/pgmspace.h>
3

4
prog_uint8_t    c1[] = {1,2,3,4};
5

6
int
7
main(void)
8
{
9
        return 0;
10
}

...ergibt folgendes .map-File:
1
 *(.progmem.gcc*)
2
 *(.progmem*)
3
 .progmem.data  0x0000008c        0x4 main.o
4
                0x0000008c                c1
5
                0x00000090                . = ALIGN (0x2)
6
 *(.init0)

Alles in Sahne, aus meiner Sicht...
OP #438608
Lesenswert?

hm ich verstehe es auch nicht
1
#include <inttypes.h>
2
#include <avr/signal.h>
3
#include <avr/eeprom.h>
4
#include <avr/pgmspace.h>
5
#include <avr/delay.h>
6
#include <stdio.h>
7
#include "uart.h"
8

9
prog_uint8_t c1[] = {0x00, 0x00, 0x01,    // Oscillator on
10
                        0xFF};
11
uint8_t PROGMEM c2[] = {0x07, 0x00, 0x00,    // Display control           PT1-0=00, VLE1-0=00, SPT=0, GON=0, DTE=0, CL=0, REV=0, D1-0=00
12
                        0x02, 0x04, 0x00,    // LCD Drive AC control      FLD1-0=01, B/C=0, EOR=0, NE5-0=000000
13
                        0x04, 0x00, 0x00,    // Power control (2)         CAD=0
14
                        0x0C, 0x00, 0x01,    // Power control (3)         VC2-0=001
15
                        0x0D, 0x06, 0x06,    // Power control (4)         VRL3-0=0110, PON=0, VRH3-0=0110
16
                        0x0E, 0x00, 0x00,    // Power control (5)         VCOMG=0, VDV4-0=00000, VCM4-0=00000
17
                        0xFF};

und im MAP dann
1
 *(.progmem.gcc*)
2
 *(.progmem*)
3
 .progmem.data  0x0000008c       0x6d main.o
4
                0x000000a6                c4
5
                0x0000008c                c2
6
                0x000000aa                c5
7
                0x0000009f                c3
8
                0x000000fa                . = ALIGN (0x2)
9
 *fill*         0x000000f9        0x1 00
10
 *(.init0)
11

12
                0x000015da                _etext = .
13

14
.data           0x00800100      0x5b4 load address 0x000015da
15
                0x00800100                PROVIDE (__data_start, .)
16
 *(.data)
17
 .data          0x00800100      0x5ad main.o
18
                0x00800102                ascii_tab
19
                0x00800644                c1
20
                0x00800642                backcolor

wie man sieht c1 liegt eben nicht da wo c2 bis c4 liegen !

Ich habs jetzt eben so gemacht das ich mit
1
uint8_t PROGMEM c2[].....

arbeite, das geht und ich vergeude keine Zeit bei der Fehlersuche.

Gruß Hagen

PS: welchen f..k formatierungstag muß ich eingeben das der Source als 
Source angezeigt wird ?
1
 ...
 scheint ja nicht zu funktionieren ?
Moderator Persönliche Seite #438635
Lesenswert?

1
#include <avr/signal.h>
2
...
3
#include <avr/delay.h>
deutet darauf hin, dass du eine ziemlich alte Version der Bibliothek
nimmst.  <avr/signal.h> ist ersatzlos gestrichen und sein vormaliger
Inhalt in <avr/interrupt.h> aufgegangen (wo er von vornherein hin
gehört hätte), und <avr/delay.h> heißt jetzt <util/delay.h>.

Hmm, andererseits habe ich gerade im CVS nachgeguckt, da hat sich
nichts Wesentliches geändert seither.
OP #438664
Lesenswert?

"deutet darauf hin, dass du eine ziemlich alte Version der Bibliothek
nimmst. "

Das stimmt allerdings. Ich hatte zwar schon die neuste Version vom GCC + 
Lib installiert aber noch nicht die Zeit gefunden alles darauf 
umzustellen. Solltes es doch mal machen bevor ich rum"meckere" ;) Bin 
halt ziemlich konservativ wenn es um meine Werkzeuge geht.

@Patrick: danke für den Hinweis.

Gruß Hagen

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren