Hi, How can I config the UCFG1 ( system configuration for clock, watchdog enz ) for a LPC controller in C ? And how can I use the 32 bytes eprom ? I tried the following but the compiler returnes an error //xdata char _at_ 0x10 ; //xdata char UCFG1 _at_ 0xFD00 = 6; //xdata char UCFG1 = 8 _at_ 0xFD00; //xdata char UCFG1 _at_ 0xFD00 = 0x7B; //pdata const UCFG1 _at_ 0xFD00=4; //pdata const UCFG1 _at_ 0xFD00; //UCFG1=222;// not an error here // but it does't work either thanx! geert
Read the manual - initialisations are not allowed with _at_ What processor are you using? Have you included the appropriate header file? Precisely what error does the compiler report?
Hi Andrew, // Header file for LPC764 MCU: // #include "REG764.H" // I.m using 87LPC76x contoller from // Philips ( 8051 ) // no error, but not a value: // xdata char P_UCFG1 _at_ 0xFD00; // no error, but not a value: // pdata const P_UCFG1 _at_ 0xFD00; // syntax error near _at_: // pdata const P_UCFG1=123 _at_ 0xFD00; // syntax error: // xdata char P_UCFG1=123 _at_ 0xFD00; // absolute indentifier illegal: // xdata char P_UCFG1 _at_ 0xFD00=2; // syntax error: // pdata const P_UCFG1 _at_ 0xFD00; // invalid base adress: // sfr P_UCFG1=0xFD00; // In another compiler ( Tasking ) // this works: // _rom char UCFG1 _at(0xFD00) = 0x7B // Keil: missing ';' before 'char' // In Keil assembler is works like this: // org 0fd00h // db 123 // the next is strange: compiler does // not return an // error, but UCFG1 // is not listed in REG764.H. It has // no effect. // UCFG1=222; // UCFG1 & UCFG2 is EPROM, nor RAM, // not SFR of normal ROM ( code )
// Header file for LPC764 MCU: // #include "REG764.H"
// no error, but not a value: // xdata char P_UCFG1 _at_ 0xFD00;
// syntax error near _at_: // pdata const P_UCFG1=123 _at_ 0xFD00;
// no error, but not a value: // pdata const P_UCFG1 _at_ 0xFD00; // syntax error: // pdata const P_UCFG1 _at_ 0xFD00;
// In another compiler ( Tasking ) // this works:
// the next is strange: compiler does // not return an // error, but UCFG1 // is not listed in REG764.H. It has // no effect. // UCFG1=222;
// UCFG1 & UCFG2 is EPROM, nor RAM, // not SFR of normal ROM ( code )
Hi andrew, thanx again for fast your reply! You are right that I cannot use the same code in different compilers. (unless ANSI C only) the reason I posted that code whas that I know how to solve the problem in Tasking C and also in Keil assembler, but not in Keil C. ( In Tasking:
_rom char UCFG1 _at(0xFD00) = 0x7B
If you know how to do it in Keil assembler, why not just do it in assembler!? In this case, I don't think there is anything to gain in doing it in 'C'; in fact, assembler might even be better, as it allows you to write numbers in binary - which is easier to read when you're setting bit patterns (in 'C', you'd have to convert it to Hex). Just create a little assembler file to set these two ROM "registers" - you don't even have to worry about C/Assembler interfacing, as there is nothing to "call" or be called; it just sets these 2 locations at build time.
When posting code to the forum, please enclose it within <pre> and </pre> tags (it gives you a monospaced font, and that lovely tuquoise tint!) Are you complaining about my lovely turquoise tint? :-) Jon