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'm trying to put 2 config chars into ROM (user makes a change which the ROM remembers during power down). However on compiling I get: 'error C142: illegal initialization' and then 'warning C34: 'code' : missing declaration specifiers The code I am using is as follows: code const unsigned char Config1 = 0x00; code const unsigned char Config2 = 0xA0; Can anyone tell me what is going on. Thanks
you have only to correct the order in your lines to: const unsigned char code name = ...
Hi Frank I started with that earlier on today and I get different errors. From the way Keil is formatting it looks like it's thinking 'code' is the variable name. When I change the code as you said I get the following errors: 'error C142: illegal initialization' 'error C42: 'code': not in formal parameter list Any ideas
Compiles with no errors here. Which version are you using?
Version 3
Are you talking about C51 or C166 (as the thread header suggests) ? Because in C166, there is no such thing as code keyword. - mike
"user makes a change which the ROM remembers..." How will the ROM remember it...?
I'm using a C166. The idea is that I have two bytes stored in some sort of non volatile memory that I can change at runtime. As I make changes to the attached hardware, my software stores the values in NV memory, which can then be recalled upon next power up and used to set up the hardware.
Now that we know that it's about C166, it's easy to say why the compiler complained. There is no code keyword, so naturally the offending code looks like rubbish to the compiler. As for the use of non-volatile memory in your application, I'm not at all sure how your are going to achive what you just described with that code. I hope you know what your are doing... Regards, - mike
There lies the problem, I've only been on this chip for a week. I'm assuming it has some sort of internal EEPROM that can be read/written at runtime. Don't tell me I have to put something external on for just two bytes.
there is no such thing as code keyword. This is replaced by const.
Exactly which C166 derivative are you using? http://www.keil.com/dd/cl/all/166.htm Jon
Does a const value allow you to change it at runtime and retain it's value on power loss?
To the best of my knowledge, there are no MCUs with on-chip EEPROM among C166 derivatives. There are chips with on-chip flash ROM, but apparently that's not what you are after. So yes, you'll have to put something external on for just two bytes. But really we should not be the ones to explain you all this. It's all in the datasheet of the chip you are using. Just read it. Regards, - mike
Thanks for your help Mike. I'm still waiting for the databook. I just didn't want to sit on my hands until it arrived.
"I'm still waiting for the databook. I just didn't want to sit on my hands until it arrived." Pardon?! Welcome to the 21st Century - don't wait for a clumsy databook, download it now! http://www.keil.com/dd/cl/all/166.htm