We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
My system use Cygnal C8051f020.The program is with "#include <c8051f020.h>",which be compiled and specified " compiling shanghai.c... SHANGHAI.C(27): error C146: 'P6': invalid base address SHANGHAI.C(30): error C146: 'P4': invalid base address SHANGHAI.C(466): error C202: 'CE': undefined identifier SHANGHAI.C(467): error C202: 'CLE': undefined identifier " In the program ,I define: sbit CE = P4^4; sbit CLE = P6^5; First ,I think that 'main()' didn't call the headfile(C8051F020.h).But "P7"can use in the program everywhere,which be defined in C8051F020.h. How can I solve this? Thanks for help!
Only SFRs with addresses divisible by 8 are bit-addressable. The bit-addressable SFRs are highlighted in Table 12.2 in the Data Sheet - you can see that neither P4 nor P6 is bit-addressable: http://www.keil.com/dd/docs/datashts/cygnal/c8051f02x.pdf
Thank you! I didn't take notice of "SFRs with addresses ending in 0x0 or 0x8 (e.g. P0, TCON, P1, SCON, IE, etc.) are bit-addressable as well as byte-addressable. All other SFRs are byte-addressable only." in the datasheet.
"I didn't take notice of ... the datasheet." That way lies doom! Now would be a good time to sit down and invest some time in a thorough reading of the Data Sheet This investment will pay dividends in saving you loads of time with problems like this in the future!
Note that this is also stated in the C51 Manual: "Not all SFRs are bit-addressable. Only those SFRs whose address is evenly divisible by 8 are bit-addressable." http://www.keil.com/support/man/docs/c51/c51_le_sbittype.asp