Hi, I'm usinge CYGNAL C8051F020. I have a C8051F020.H include file. But some definitions are missing. I would like to add the UART1 definition. In the file the sfr SCON1 was already there, but not the sbit associated with it. But SCON0 was all defined so I have made a copy of it and I only changed the '0' with '1' for each name. So I've add this: /* SCON1 0xF1 */ sbit SM01 = SCON1 ^ 7; /* SERIAL MODE CONTROL BIT 0 */ sbit SM11 = SCON1 ^ 6; /* SERIAL MODE CONTROL BIT 1 */ sbit SM21 = SCON1 ^ 5; /* MULTIPROCESSOR COMMUNICATION ENABLE */ sbit REN1 = SCON1 ^ 4; /* RECEIVE ENABLE */ sbit TB81 = SCON1 ^ 3; /* TRANSMIT BIT 8 */ sbit RB81 = SCON1 ^ 2; /* RECEIVE BIT 8 */ sbit TI1 = SCON1 ^ 1; /* TRANSMIT INTERRUPT FLAG */ sbit RI1 = SCON1 ^ 0; /* RECEIVE INTERRUPT FLAG */ The problem is I get an error ERROR C146 IN LINE 161 OF C8051F020.H: 'SCON1' invalid base adress Why, what am I doing wrong ?, how can I add my own definitions. Thank you, gasma1975.
Only those SFRs that are located on 8-byte boundaries are bit-addressable. Jon
Hi, I'm not sure to understand, why can I access each bit in sfr SCON0 and not SCON1, they have the same syntax. What do you mean ? Thank you,
"I'm not sure to understand, why can I access each bit in sfr SCON0 and not SCON1, they have the same syntax." Is SCON0's address (0x98) evenly divisible by 8? Yes, therefore it is also bit-addressable. Is SCON1's address (0xF1) evenly divisible by 8? No, therefore it is not bit-addressable, despite the similarity between the bits it contains and the bits SCON0 contains.