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.
I am just getting started in coding the cypress FX2 in C. I was trying a very simple, port toggle example code. But I get the following error "FX2REGS.H(38): error C129: missing ';' before 'GPIF_WAVE_DATA'"
I haven't changed the FX2REGS.H, its as is from the INC folder. I searched for the error, keil online database says, it might be due to a missing ";" in the previous line. Here's the part of the code that's causing the error (line 8 here).
#ifdef ALLOCATE_EXTERN #define EXTERN #define _AT_ _at_ #else #define EXTERN extern #define _AT_ ;/ ## / #endif EXTERN xdata volatile BYTE GPIF_WAVE_DATA _AT_ 0xE400; EXTERN xdata volatile BYTE RES_WAVEDATA_END _AT_ 0xE480;
#define _AT_ ;/ ## /
HUH?
This is what the comments say before the defines
// The Ez-USB FX2 registers are defined here. We use FX2regs.h for register // address allocation by using "#define ALLOCATE_EXTERN". // When using "#define ALLOCATE_EXTERN", you get (for instance): // xdata volatile BYTE OUT7BUF[64] _at_ 0x7B40; // Such lines are created from FX2.h by using the preprocessor. // Incidently, these lines will not generate any space in the resulting hex // file; they just bind the symbols to the addresses for compilation. // You just need to put "#define ALLOCATE_EXTERN" in your main program file; // i.e. fw.c or a stand-alone C source file. // Without "#define ALLOCATE_EXTERN", you just get the external reference: // extern xdata volatile BYTE OUT7BUF[64] ;// 0x7B40; // This uses the concatenation operator "##" to insert a comment "//" // to cut off the end of the line, "_at_ 0x7B40;", which is not wanted.
Where does it say that after preprocessor expansion of the _AT_ macro, the syntax will still be valid?
I have no idea. I am just getting started in C. What exactly is wrong here? The #define _AT_ ?
Try using the "PREPRINT" compiler directive and examine the preprocessor output.
http://www.keil.com/support/man/docs/c51/c51_cm_ifile.htm
well, I need more help.
I tried using preprint in debug. FX2REGS.H PREPRINT
Is that correct? I get "error34: undefined identifier"
I have no idea. I am just getting started in C. You need to read a bit more before you start banging the keys. There are many good books about C, my favorite is Kochan: programming in ANSI C
If, as you say, you are just getting started in C, get your feet wet writing code for the PC and then, when you have the basics down pat, have a go at the micros
Erik
Let me rephrase: I am getting started in embedded C. I am in no way an expert on C. But I have coded in C on PC, not Microcontrollers. All my uC was in assembly.
"I tried using preprint in debug. FX2REGS.H PREPRINT"
Compile the C source file(s) that include FX2REGS.H.
I get the same error "*** error 34: undefined identifier"
Do you actually understand what the 'C' preprocessor is, and what it does?
If not, it's time to go back to the 'C' textbook; this is standard stuff - nothing peculiar to C51.