Mehr "volatile" geht wohl kaum und trotzdem "KLAUT" mir der Compiler meinen Code. Wo muss das "volatile" denn hin, damit der compiler meinen Code NICHT rausschmeisst ?????
Die Funktion "ShiftOut() " welche ich vom Hauptprogramm aufrufe, wird rausgeschmissen, (wegoptimiert)
wie kann das denn sein ?????
Wichtig: ANSI-C tauglich
Code:
typedef volatile union
{
struct
{
int data : 16;
int reserved0 : 16;
} bits;
U32 value;
} SSP1DR_TypeDef;
#define LPC_SSP1DR (* (SSP1DR_TypeDef *)(0x40030008))
typedef volatile union
{
volatile struct
{
volatile int TFE : 1;
volatile int TFN : 1;
volatile int RNE : 1;
volatile int RFF : 1;
volatile int BSY : 1;
volatile int reserved0 : 27;
} bits;
volatile U32 value;
} SSP1SR_TypeDef;
#define LPC_SSP1SR (* (volatile SSP1SR_TypeDef *)(0x4003000C))
unsigned char data;
void ShiftOut()
{
while (LPC_SSP1SR.bits.BSY) ; /* wait until BSY becomes zero */
LPC_SSP1DR.value = data; /* shift out the data byte */
}
int main(void)
{
while (1)
{
data = 0xAA;
ShiftOut();
}
}
Compiler: IAR Embedded Workbench 5.4
fassungslos...
Siro
Lesezeichen