View previous topic :: View next topic |
Author |
Message |
beananimal
|
Posted: Tue Dec 04, 2007 2:48 pm Post subject: EEPROM Questions |
|
|
I have ordered the BDMICRO MAVRIC-IB
It has an I2C clock (DS1307) and an AT24C256 EEPROM
The EEPROM is listed to reside at address 0x50
The project will include the EvertDekker 5" touchscreen for control. The code appears to be straight forward with the exception of the EEPROM storage of the BGF files.
So here are my questions:
1) Can I use BOTH the AVR EEPROM and the External I2C EEPROM? I need to store BGF files, and program operational/user parameters (I will eventually add the WIZB10MJ, among other items).
2) Can somebody please hold my hand through this learning process. I have read everything I can find here at the forum and in the helps but have been left somewhat confused. I am a quick learner but have no exposure to this type of programming.
Here is my crude understanding.
The $EEPROM directive tells the compiler that what follows is to be placed in eeprom. The BGF files are compiled and pushed out the eeprom during programming? Each time I program the chip, the EEPROM will be overwritten with the data that follows the $EEPROM directive? During program run, I can add data to the EEPROM as well, but reporgramming the AVR chip will destroy that data and overwrite with new data.
The $EEPLEAVE directive tells the compiler NOT to overwrite the files to the eeprom, because they are already there. However the $EEPROM and bgf code must stay in the source file as a place holder for the memory mapping? Or do I have this VERY WRONG?
On a side note: The I2C clock is listed to be at address 0x68. So I assume that I can use the Ds1307 clock example but change the address to &H68 and &H69 (From the example &HD0 and &HD1)
Somebody tell me how far off I really am!
Last edited by beananimal on Thu Dec 06, 2007 6:03 pm; edited 1 time in total |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Thu Dec 06, 2007 1:27 am Post subject: |
|
|
thats no problem, you can attach any i2c device as long as it got different address. i've attached ds1307 and i2c eeprom like at24c512 in one i2c line and got no problem with it, as long as you pull up the sda and sck line with say 1k-4k7 resistor.
you can use both of them with no problem since is very different thing (internal and external). for bgf in external eeprom check out the app note from mcselec. its detail
hope helpfull
and happy constructing, btw, whats the project doc?? |
|
Back to top |
|
|
beananimal
|
Posted: Thu Dec 06, 2007 4:27 am Post subject: |
|
|
Thank you for the reply.
Both I2C devices are already on the board from BDMICRO. I will need to add an I2C pot or two later.
I have read the app note but am still not at all clear on the questions I asked above. It helps to know that I can use both the internal and external eeprom. I would like to use the external eeprom to hold the graphics files and the internal eeprom to hold program settings and non volitile counters.
The project is a lighting timer for my aquarium. When it is complete it will control several relays to turn different lighting units on and off according to sunrise/sunset a and lunar times. It will also control dimmable fluorescent ballasts (0-10V) and keep track of bulb life.
Most of the basic code is done, I just need help details like how to best implement the EEPROM.
Once the basic system is complete, I plan to add WIZNET and a 5" Touchscreen for control. |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Thu Dec 06, 2007 6:10 am Post subject: |
|
|
why you need to store bgf on external eeprom?what is your purpose to use lcd graphic (i suppossed)? |
|
Back to top |
|
|
beananimal
|
Posted: Thu Dec 06, 2007 6:23 am Post subject: |
|
|
Yes, I will be using a 5" touchscreen (I already ordered it) and the graphics will take up a lot of space. The MAVRIC-IB has a 32K I2C EEPROM that I would like to use for this. |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Thu Dec 06, 2007 6:26 am Post subject: |
|
|
5" touch screen?? wow
the module type and manufacturer??? might want to try that |
|
Back to top |
|
|
beananimal
|
Posted: Thu Dec 06, 2007 2:03 pm Post subject: |
|
|
It is from ledsee.com very similar to the one mentioned in the App notes.
Can any of you please help with my EEPROM questions. My hardware arrives today, and I would like to get to work with some code to drive the EEPROM and I2C clock. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Thu Dec 06, 2007 9:45 pm Post subject: |
|
|
Hi beananimal,
It's Evert here
You can use both EEPROM'S at the same time, but you can only store the BGF file's to the internal-eeprom of the AVR.
You are correct that everything above the $EEPROM directive is compiled for the flash program area and everything below the $EEPROM will be compiled for the internal-eeprom in an YourProject.eep file.
This YourProject.eep can be programmed manual to the AVR or you can goto Options -> programmer and check the box "upload code and data" then the internal-eeprom wil be programmed at the same time as the flash area. The eeprom area will be complete erased before programmed.
If you have the fuse bit "EEPROM memory is preserved through the Chip Erase" off, then the internal-eeprom will always be erased when programming the flash area.
While compiling your program the existing Yourproject.eep will be erased and a new one will be created during compiling. To prefent that Bascom will delete Yourproject.eep you can use $EEPLEAVE. This only used if the eep file is created with an external tool, for normal use you must not use this.
Keep in mind that BGF's in the program area are called with the SHOWPIC statement and the BGF'S in the internal-eeprom area with SHOWPICE.
Next answer: You can store your operational/user parameters in the internal-eeprom, but as told you above these settings are lost when reprogramming the internal-eeprom. The second problem that you have with the internal-eeprom is that you don't know where the BGF'S are stored, so you can have a conflict with you saved settings, keep an eye on this one.
The Ds-1307 has NOT an selectable i2c address, so the base address is &HD0 and &HD1 just like the sample.
To read and write to the external-eeprom, try the i2c.bas sample.
Important is that you make your program's step by step. For example make first an small program that shows text on the display, then the next step, show a image on your display, if that is working try showing an image from the eeprom, then connect the touchscreen, etc.......
Rome wasn't build in one day.
Happy programming. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
beananimal
|
Posted: Thu Dec 06, 2007 10:51 pm Post subject: |
|
|
Thank you kindly for the reply!
It is bothersome that I can not use the external EEPROM for the BGF files. I will have to limit my interface to what can fit on the INTERNAL EEPROM. I can then use the external EEPROM to store the user settings and counters. Does this sound like a good plan?
Your explanation has helped me greatly! It gives me a foundation to build on as IU move forward with this project.
The documentation that came with the MAVRIC board lists the DS1307 at a different address. The manual can be found here. On page 13 it says
Up to 128 devices can coexist on the I2C bus. The MAVRIC-IB board incorporates 2 such devices, the Dallas
DS1307 Real Time Clock and the 24C256 Serial EEPROM. The DS1307 resides at the fixed I2C address 0x68 and
the AT24C256 serial EEPROM resides at I2C address 0x50. http://www.bdmicro.com/mavric-ib/mavric-ib.pdf Am I just missing something obvious? |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Fri Dec 07, 2007 1:07 am Post subject: |
|
|
ok nice module, though you can do it yourself
ok then, thats the address of the write access as for the read access it should be 0x69 and 0x51
from there you can do anything
as for the external eeprom to store bgf, look at mcs app note. it uses i2c eeprom for bgf file so you can get bigger picture |
|
Back to top |
|
|
beananimal
|
Posted: Fri Dec 07, 2007 2:38 am Post subject: |
|
|
I want to use the MAVRIC as a development platform. Once I get the design worked out I will build a dedicated board. I have no desire to solder TQFP or similar packages! I fear my soldering skills are not that polished. I wish to devote my time to development, not troubleshooting a board design and learning to solder things I can not see |
|
Back to top |
|
|
ex4
Joined: 13 Jan 2006 Posts: 1062 Location: indonesia
|
Posted: Fri Dec 07, 2007 2:31 pm Post subject: |
|
|
hehehehe, TQFP. mine was only PDIP package |
|
Back to top |
|
|
|