Embedded C: Ability to access some members of the structure, but not others

Problem

In my personal project, I have a structure defined in the UART abstraction library (let it be called UART.c and UART.h), which I did for AVR.

In UART.h:

typedef struct ST_UARTRX_MESSAGECONTENTS{
 uint8_t u_command[3];          //Command 
 uint32_t u32_value;            //Parameter for Command
 boolean b_newValue;    //Is there new value written here
 boolean b_Error;       //Is there an error with this message
} ST_UARTRX_MESSAGECONTENTS;

volatile ST_UARTRX_MESSAGECONTENTS st_uartRX_MessageContents;

Thus, basically it is a structure that contains a UART message, has "b_newValue", which is the flag for receiving a new message. The message is "received" when the AVR receives a new line "\ n".

In the header file of another file (call "foo.h"): I include my "UART abstraction library" and put it in the header:

extern volatile ST_UARTRX_MESSAGECONTENTS st_uartRX_MessageContents;

But then in foo.c, I try to access "b_newValue":

if(st_uartRX_MessageContents.b_newValue){
    st_uartRX_MessageContents.b_newValue = TRUE;  
    fsm_state = ST_STOREMACRO;
}

But "if" is never entered, even if my debugger says that the value of struct is really true:

enter image description here

, if. "Step", !

typedef :

typedef enum{FALSE, TRUE} boolean;

,

ASM, , R24 b_newValue, 0x00, 0x01, .

uartTX_sendArray(st_uartRX_MessageContents.u_command, sizeof st_uartRX_MessageContents.u_command);
delay_ms(2000);
if(st_uartRX_MessageContents.b_newValue){
    st_uartRX_MessageContents.b_newValue = TRUE;  
    fsm_state = ST_STOREMACRO;
}

"UART: ", ascii , ! , foo.c "", "b_newValue" .

. , .

+4
1

, , struct, UART.h

volatile ST_UARTRX_MESSAGECONTENTS st_uartRX_MessageContents;

( UART.h ) , , , . UART.c

extern volatile ST_UARTRX_MESSAGECONTENTS st_uartRX_MessageContents;

UART.h.

+1

All Articles