Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th December 2004, 12:22 PM   (permalink)
Default Eeprom Prob (PIC16f628a)

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
__________________
The first rule of mstechca club is do not talk about mstechca club.
http://www.electro-tech-online.com/s...induser&u=1245
2camjohn is offline  
Old 10th December 2004, 01:36 PM   (permalink)
Default

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).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 10th December 2004, 02:15 PM   (permalink)
Default

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?
__________________
The first rule of mstechca club is do not talk about mstechca club.
http://www.electro-tech-online.com/s...induser&u=1245
2camjohn is offline  
Old 10th December 2004, 03:01 PM   (permalink)
Default

Quote:
Originally Posted by 2camjohn
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 10th December 2004, 03:34 PM   (permalink)
Default

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
__________________
The first rule of mstechca club is do not talk about mstechca club.
http://www.electro-tech-online.com/s...induser&u=1245
2camjohn is offline  
Old 10th December 2004, 03:56 PM   (permalink)
Default

Quote:
Originally Posted by 2camjohn
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 13th December 2004, 12:01 PM   (permalink)
Default

I have tried this, whenever I enter anything in that grid it says Data Verify Error when I program and the chip doesnt work ??
__________________
The first rule of mstechca club is do not talk about mstechca club.
http://www.electro-tech-online.com/s...induser&u=1245
2camjohn is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 01:05 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker