I have the following code and MPLABX XC8 compiler gives this error:
error: expression is not assignable
U1ERRIRbits.RXFOIF ? uart1.oerr = 1 : uart1.oerr = 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
Here is the relevant code section:
typedef union {
struct {
bool ferr : 1; // FERIF Framing Error
bool aerr : 1; // ABDOVF Error
bool oerr : 1; // RXFOIF Error
bool ready : 1; // Data Ready to be read
uint8_t reserved : 4;
};
uint8_t status;
}uart1_status_t;
static volatile uart1_status_t uart1;
U1ERRIRbits.RXFOIF ? uart1.oerr = 1 : uart1.oerr = 0;
Same thing does not give error when I use
if (U1ERRIRbits.RXFOIF)
uart1.oerr = 1;
else
uart1.oerr = 0;
Do not understand why?