Re: 8051: writing to memory in the program



In article <1168525923.353103.319400@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, wanwan <ericwan78@xxxxxxxxx> writes
so does anyone know how I can read/write on the flash memory using Keil
in C?

Yes. By not TOP posting. Other would have flamed you for that.

the only information I found about it is an example code on the Keil
site.

Then that is your answer..... Keil are very good with their support answers and examples.

With the example code , it shows memory write to idata, pdata, data,
and xdata. I'm kind of confused by these variables.

Then you need to start with the basic 8051 architecture guide BEFORE you start to program ANYTHING.

Try
http://quest.phaedsys.org/

Document number 4 is
http://www.phaedsys.demon.co.uk/chris/papers/QuEST4_1.pdf

Which is a primer for the 8051 with the Keil compiler.

When you understand the 8051 hardware architect you will understand the multiple memory spaces this Harvard Architecture part has and therefore the various i,b,p,a, Data and CODE spaces it has.

Then the method of writing to flash will depend on the target 8051. With some you have to write byte at a time and some it is larger blocks.


And it has no
information about memory read.

After you have declared the variable, it's size and location etc you can just read it (and write to it if it is RAM.)

(And oops, AT89s52 has 256 bytes of RAM, not 2kb)

We know.



Chris Hills wrote:
In article <1168498952.085962.157090@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, -jg
<Jim.Granville@xxxxxxxxx> writes
>
>wanwan wrote:
>> I'm learning the 8051 type microcontroller now and using the Atmel
>> 89s52 microcontroller. There are 2kb of RAM and 8kb of flash memory.
>>
>> I'd like my program to be able to write some data to memory while
>> running, so these data can be remembered when power down and can be
>> retrieved at power up.
>>
>> Is there a way to do it? How do I do such a write with embedded c?
>>
>> Thanks
>
>The AT89S52 does not have 2K RAM ?
It is the flash he needs to write to so the RAM is irrelevant here
anyway,

>What I think you are seeking, is a self-pgm, or what is commonly called
>In Application Programming.

Not at all. This is for updating the application in code space not
storing data between powering down and up.

>and choose any device that has SelfPgmMemory column entry.

He is talking about DATA space not CODE space.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@xxxxxxxxxxxx www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@xxxxxxxxxxxx www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



.



Relevant Pages

  • Re: 8051: writing to memory in the program
    ... so does anyone know how I can read/write on the flash memory using Keil ... There are 2kb of RAM and 8kb of flash memory. ... He is talking about DATA space not CODE space. ...
    (comp.arch.embedded)
  • Re: embedded questions!!!
    ... >>> that they occupy the exact same memory? ... If you look at the above list and think about Harvard architectures ... and if the code space is the only non-volatile memory present. ... passing around pointers to data which may be either in code space or ...
    (comp.arch.embedded)
  • Re: Overview Of New Intel Core i7(Nehalem) Processor
    ... If x86 had serious i/d space separation, and Microcrap used it, all ... Code space being in different chips, on a different bus is the ideal. ... The memory can be logically divided into sections and security can be ... stacks in the same address space as the subroutine code itself! ...
    (sci.electronics.design)
  • Re: question makeing run-time image
    ... psize represents the physical size of the section in memory, ... > Code space full, fixing up MediaRenderer.dll to ram space ...
    (microsoft.public.windowsce.platbuilder)
  • Re: C vs C++ in Embedded Systems?
    ... >>FWIW, at the turn of the century I worked on an application ... >of code space. ... Memory holds more than programs. ... In terms of conventional "embedded programming," we paid essentially ...
    (comp.arch.embedded)