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.

Eeprom Prob (PIC16f628a)

Status
Not open for further replies.

2camjohn

Member
For some strange reason I am unable to write values to the EEPROM on my PIC16f628a at program time. This is fine after the first time the program runs as it reads and writes a particular value each time the code loops.

I would like to be able to know if the eeprom has been programmed or not.


My question is:

How can I test the eeprom value at run time to see if it has been programmed?

In otherwords what does an unprogrammed eeprom address read as?

Thanks
John
 
You're not very clear what you mean?, if you mean the EEPROM data memory, the routines for reading it are listed in the datasheet.

However, if you mean the EEPROM program memory you can't read it from within the program, the Harvard architecture of the PIC means that program and data memory are totally seperate, and the program memory can't access itself.

All unprogrammed EEPROM are just like unprogrammed EPROM, all bits read '1', and programming consists of changing '1' to '0', you can't change them the other way.

So the EEPROM data memory is $FF when blank (as it's 8 bit), and the program memory is $3FFF (for a 14 bit PIC).
 
Sorry I will try and be more clear.

In the HLL I use the data eeprom is divided into bytes, with a byte for the address index.

When my chip is powered up it reads the first byte from the eeprom at address 0 and uses the value which was saved the last time the code was executed.

This value can then be changed by the code depending on user interaction. I am using the eeprom so that this value persists even if the power is removed.


The problem is that the first time the chip is programmed there is no value in this first byte of the data eeprom. This causes it to act crazy.
At the moment to solve this a value is inserted into this part of the memory when a button is held on power up, so that the first time the chip is powered up after it has been programmed I can hold this button to put a value in the data eeprom. But this is more of a hack than a good solution.


When you say the eeprom is all 1s, does that mean the first byte would be 255?
In that case instead of checking for a button press I can check the first byte of the eeprom to see if it is the value 255?

Does that sound correct?
 
2camjohn said:
When you say the eeprom is all 1s, does that mean the first byte would be 255?
In that case instead of checking for a button press I can check the first byte of the eeprom to see if it is the value 255?

Does that sound correct?

Yes, when blank it reads 255 (in decimal).

Or you could simply program a byte there as part of the programming process - this is trivial in assembler, or in most programmer software during the programming process, but how to do it in your HLL depends entirely on the compiler.
 
I am using WinPicProg, can you explain how I would do it in that??

I have tried to edit the eeprom grid, but when I verify the chip it comes back as blank (FF).


Is it possible my HLL is overriding the programmer by making it blank in assembler code?

What should I look for in the assembler code that is related to eeprom data values?


Thanks
 
2camjohn said:
I am using WinPicProg, can you explain how I would do it in that??

I have tried to edit the eeprom grid, but when I verify the chip it comes back as blank (FF).

Load the hexfile you want to program, edit the byte in the EEPROM grid, then program the chip.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top