Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure puis, j'ai déclaré la structure. Cela prend visible de la
Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure puis, j'ai déclaré la structure. Cela prend visible de la
Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure puis, j'ai déclaré la structure. Cela prend visible de la
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure
puis, j'ai déclaré la structure. Cela prend visible de la mémoire RAM qui
est dans mon circuit très limitée.
Est-ce que dans ce cas là cela consomme effectivement un octet de mémoire
?
Devrais je préférer des déclaration avec des #define ?
Stéphane
Voici comment un registre est déclaré :
dans le fichier *.c
=========== > volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
dans le fichier *.c
volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure
puis, j'ai déclaré la structure. Cela prend visible de la mémoire RAM qui
est dans mon circuit très limitée.
Est-ce que dans ce cas là cela consomme effectivement un octet de mémoire
?
Devrais je préférer des déclaration avec des #define ?
Stéphane
Voici comment un registre est déclaré :
dans le fichier *.c
=========== > volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
dans le fichier *.c
volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
Bonjour,
Dans un programme embarqué, j'ai déclaré les registres en tant que
structure
puis, j'ai déclaré la structure. Cela prend visible de la mémoire RAM qui
est dans mon circuit très limitée.
Est-ce que dans ce cas là cela consomme effectivement un octet de mémoire
?
Devrais je préférer des déclaration avec des #define ?
Stéphane
Voici comment un registre est déclaré :
dans le fichier *.c
=========== > volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
extern volatile CONFIG2STR _CONFIG2 @0x0000001E;
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
dans le fichier *.c
volatile CONFIG2STR _CONFIG2; /* Configuration Register 2 */
merci pour ces suggestions.
Il semble que la définition faite par motorola ne prennent finalement pas
d'octets en RAM.
Son avantage est de pouvoir grouper des vits au sein d'un même champs et
d'adresser ce champs.
Si par exemple dans un registre 8 bits, il y a trois bits au milieu qui
correspondent à une info, il est aisé avec cette méthode d'accéder à ces
trois bits sous forme d'un champ unique.
Excellent pour la lisibilité. Par contre, je ne suis pas sûr que cela se
porte bien. J'essairais sur un autre micro Philips
merci pour ces suggestions.
Il semble que la définition faite par motorola ne prennent finalement pas
d'octets en RAM.
Son avantage est de pouvoir grouper des vits au sein d'un même champs et
d'adresser ce champs.
Si par exemple dans un registre 8 bits, il y a trois bits au milieu qui
correspondent à une info, il est aisé avec cette méthode d'accéder à ces
trois bits sous forme d'un champ unique.
Excellent pour la lisibilité. Par contre, je ne suis pas sûr que cela se
porte bien. J'essairais sur un autre micro Philips
merci pour ces suggestions.
Il semble que la définition faite par motorola ne prennent finalement pas
d'octets en RAM.
Son avantage est de pouvoir grouper des vits au sein d'un même champs et
d'adresser ce champs.
Si par exemple dans un registre 8 bits, il y a trois bits au milieu qui
correspondent à une info, il est aisé avec cette méthode d'accéder à ces
trois bits sous forme d'un champ unique.
Excellent pour la lisibilité. Par contre, je ne suis pas sûr que cela se
porte bien. J'essairais sur un autre micro Philips
Je voulais dire
# define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
au lieu de
# define _CONFIG2 *((volatile CONFIG2STR*)0x0000001E)
car sinon il y a un problème de priorité des opérateurs (. plus
prioritaire que *).
Pour résumer :
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
#define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
HalfWolf
Je voulais dire
# define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
au lieu de
# define _CONFIG2 *((volatile CONFIG2STR*)0x0000001E)
car sinon il y a un problème de priorité des opérateurs (. plus
prioritaire que *).
Pour résumer :
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
#define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
HalfWolf
Je voulais dire
# define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
au lieu de
# define _CONFIG2 *((volatile CONFIG2STR*)0x0000001E)
car sinon il y a un problème de priorité des opérateurs (. plus
prioritaire que *).
Pour résumer :
dans le fichier *.h
=========== > /*** CONFIG2 - Configuration Register 2 ***/
typedef union {
byte Byte;
struct {
byte RSTEN :1; /* RST Pin Function Selection */
byte IRQEN :1; /* IRQ Pin Function Selection Bit */
byte IRQPUD :1; /* IRQ Pin Pullup Control Bit */
byte OSCOPT0 :1; /* Selection Bits for Oscillator Option */
byte OSCOPT1 :1; /* Selection Bits for Oscillator Option */
byte :1;
byte :1;
byte :1;
} Bits;
struct {
byte RSTEN :1;
byte IRQEN :1;
byte IRQPUD :1;
byte OSCOPT :2;
byte :1;
byte :1;
byte :1;
} MergedBits;
} CONFIG2STR;
#define _CONFIG2 (*((volatile CONFIG2STR*)0x0000001E))
#define CONFIG2 _CONFIG2.Byte
#define CONFIG2_RSTEN _CONFIG2.Bits.RSTEN
#define CONFIG2_OSCOPT0 _CONFIG2.Bits.OSCOPT0
#define CONFIG2_OSCOPT1 _CONFIG2.Bits.OSCOPT1
#define CONFIG2_IRQEN _CONFIG2.Bits.IRQEN
#define CONFIG2_IRQPUD _CONFIG2.Bits.IRQPUD
#define CONFIG2_OSCOPT _CONFIG2.MergedBits.OSCOPT
HalfWolf