Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Data EEPROM of PIC questions

Status
Not open for further replies.
Any clue? The datasheet states only how to read and write into it. I couldn't find any notes from microchip site too.
Does the program memory store the program instructions?
 
Still couldn't figure it out. Isn't the program stored in the location start from 0x0000? Then for the flash program memory? To store more program instructions start from the 0x1000?
I'm refering to PIC16F88.
 
Page 11, figure 2.1 - shows 4K of program memory from 0x0000 to 0x0FFF - that's it, total program memory. If you try and run the program counter past that end address it loops back to 0x0000 again.
 
Nigel Goodwin said:
Page 11, figure 2.1 - shows 4K of program memory from 0x0000 to 0x0FFF - that's it, total program memory. If you try and run the program counter past that end address it loops back to 0x0000 again.
Hi,
I know about this, 4 k of program memory from 0x0000 to 0x0fff (aka on chip program memory), 2 k for each page and there are two pages.
I just don't know what's the purpose of writing to or reading from the flash. According to the datasheet,
The PIC16F87/88 devices have 4K words of program Flash with an address range from 0000h to 0FFFh. Addresses above the range of the respective device will wraparound to the beginning of program
memory.
So flash program memory is also on chip program memory? Why we need to write into our program memory since the program is already there?

Thanks
 
bananasiong said:
So flash program memory is also on chip program memory? Why we need to write into our program memory since the program is already there?

I don't understand what you're asking? - 'program memory' and 'flash memory' are the same thing - you've got 4K of memory that goes from 0x0000 (the reset vector) to 0x0FFF (the end of memory). That's it, your total program memory - nothing else.
 
You read and write to flash to store/retrieve data. I store messages as 2 x 7 bit ascii characters per location and have filled a 2K bank with text (4000 chars). If you wanted to do a data logger then you can store lots of readings as long as they don't arrive too fast. Bootloaders write code to flash.

One nice thing about the USB enabled pics is the bootloader. The bootloader sits in the first 2K of memory and your program gets sent via USB and is written in the other 30k of flash.

Mike.
 
Nigel Goodwin said:
I don't understand what you're asking? - 'program memory' and 'flash memory' are the same thing - you've got 4K of memory that goes from 0x0000 (the reset vector) to 0x0FFF (the end of memory). That's it, your total program memory - nothing else.
Since it is the program memory, I don't see what's the point of doing this:
**broken link removed**
Let's say I read from 0x0000, what will I get? Isn't it
goto Initialize (my program begins with this usually)?
Then I will get the hex. representation of the instruction 'goto' and the location of 'Initialize'?

Pommie said:
You read and write to flash to store/retrieve data. I store messages as 2 x 7 bit ascii characters per location and have filled a 2K bank with text (4000 chars). If you wanted to do a data logger then you can store lots of readings as long as they don't arrive too fast. Bootloaders write code to flash.
Can you give more example? I know that the data can be stored in EEPROM, how about flash memory? Since it is the program memory, how come data is stored there?

Sorry for stating unclearly, but I really want to know.

Thanks
 
I think bananasiong asking if the instructions still there after power OFF & ON then why need a special EEPROM location.

He is asking why not keep all the EEPROM Read /Write codings as like a normal program (without writing to EEPROM)

For example: A COUNTER must stop in “9” & after power OFF & ON it must start from “9”.Then we press a button & store the data in the EEPROM.

He is asking why storing in the EEPROM why not save in the main program?
(Because the instructions are still there in the program they didn’t erase after power OFF)

Is this write?
 
The main difference between flash and EEPROM is the number of times you can write to it. Flash may fail after only 1000 writes, EEPROM is guaranteed for 10,000 writes but will typically last 1,000,000 writes.

EEPROM should be used to store things that may change infrequently such as customer preferences.

Flash should contain data that changes very infrequently such as the program code (changed when a bug is fixed or the code updated). You can also use flash to store data. For example, a musical doorbell may have the code and a tune programmed when it is manufactured but different tunes could be made available via the internet that could be flashed into the memory via RS232.

Mike.
 
Pommie said:
The main difference between flash and EEPROM is the number of times you can write to it. Flash may fail after only 1000 writes, EEPROM is guaranteed for 10,000 writes but will typically last 1,000,000 writes.

EEPROM should be used to store things that may change infrequently such as customer preferences.

Flash should contain data that changes very infrequently such as the program code (changed when a bug is fixed or the code updated). You can also use flash to store data. For example, a musical doorbell may have the code and a tune programmed when it is manufactured but different tunes could be made available via the internet that could be flashed into the memory via RS232.

Mike.
So ideally speaking, we write to the flash everytime we program the chip? And the chip is unusable after 1000 times programming.
If my program occupy for only 1 page, 0x0000 to 0x07ff, I can only store additional data into the second page right?

Hi Gayan, I know what EEPROM is, I'm using it to store the time of my clock ;)
 
You can store code or data in page two.

1000 writes for flash is the worst case - it is typically 100,000.

You seem to keep asking the same questions again and again. If you still have questions you should read the section "PCL and PCLATH" in the data sheet - normally section 2.2

Mike.
 
bananasiong said:
So ideally speaking, we write to the flash everytime we program the chip? And the chip is unusable after 1000 times programming.

No, it's guaranteed to have a minimum life of 1000 times, in reality it will almost certainly have a much longer life.

If my program occupy for only 1 page, 0x0000 to 0x07ff, I can only store additional data into the second page right?

No - the entire 2K is program memory, I strongly suggest you use it as such and forget about writing directly to program memory - it's NEVER a good idea to write code that modifys program memory - unless you have a seriously good reason (such as a bootloader).
 
Nigel Goodwin said:
it's NEVER a good idea to write code that modifys program memory - unless you have a seriously good reason (such as a bootloader).

Why? Storing things like,
Customer address for anti theft purposes,
Mapping tables for CDI,
String tables for different languages,
Are all reasons to write to the code area. Why do you think microchip gave you the ability to read and write to this area?

Most cars, mobile phones, network hubs, motherboards and even my DVD recorder are flash upgradable.

Mike.
 
Pommie said:
You can store code or data in page two.

1000 writes for flash is the worst case - it is typically 100,000.

You seem to keep asking the same questions again and again. If you still have questions you should read the section "PCL and PCLATH" in the data sheet - normally section 2.2

Mike.
It is because I didn't know what's the point of writing into the program memory. I thought that write the program into the program memory and I couldn't figure out why is it needed because the program is already there.
Now I know that the reading from and writing to the flash program memory section in the datasheet is refering to the data, but not the instructions.
 
bananasiong said:
It is because I didn't know what's the point of writing into the program memory. I thought that write the program into the program memory and I couldn't figure out why is it needed because the program is already there.

You're just confusing yourself, ignore that capability, or choose a PIC that doesn't include it (it's a relatively 'recent' addition) - it's rare to require it, and you almost certainly don't!.

As Pommie says, there are occasions where it's useful, although many of the applications (and the most important ones) he listed are just using it as a bootloader to reprogram the device.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top