PDA

View Full Version : eeprom how many data can store



DragonBall_6
- 2nd December 2006, 08:08
Hi all

Could I store 365 data in the eeprom??????? I am using PIC16F84A.
If can not, can u suggest me how many data that I can store in the eeprom or other places. Thanks.
************************************************** ********
For example: I want to store time 12:13 pm into a place.

a var word
c var byte
'
'some initialization
'
On INERRUPT exit

EEPROM 0, [$0c0d]
main: READ 0,a.highbyte
READ 1,a.lowbyte
c= a.highbyte - 5 ' return 7am
IF hour = c THEN ' check 7:13 am
IF second = a.lowbyte THEN '
low PORTB.0 ' motor start
ENDIF
ENDIF
GOTO main
DISABLE
exit:

'Interrupt will accur every 65.536 msec
'some program code here to calculate time using tmr0 interrupt
'

INTCON.2 = 0 ' clear flag
RESUME
END



**************************************
The return value below is it correct ???????
a.highbyte=$0c ' 12
a.lowbyte= $0d ' 13
c = 7

Melanie
- 2nd December 2006, 08:39
Have you looked at the DATASHEET for the 16F84?

If you haven't please download it from the Microchip website.

The size for the on-board EEPROM for any PIC is usually found on Page 1 of the Datasheet. You can determine if it is sufficient for your needs from there.

Please Look at the DOCUMENTATION for the EEPROM command. You can only play with BYTES... therefore...

EEPROM 0,[$0C,$0D]

or

EEPROM 0,[12,13]

DragonBall_6
- 3rd December 2006, 10:54
First of all thanks to your reply and advice.
Sorry for the mistaken. What i mean is c = a.highbyte + a.lowbyte.

I have looked on the datasheet for the PIC16F84A, the space is 64 bytes for eeprom. I know it is impossible for me to store in the 365 data into the eeprom.
Do you have any suggestion?
How about other places such as program memory or RAM?
I am thinking of using PIC16F876 but it is only 256 bytes only.

I just want to store the time(sunrise time) for 365 day to anything places that available so that i can read it thru the date.
for example: 1 jan 06 the sunrise time is 6:10 am
2 jan 06 the sunrise time is 6:15 am
and so on.

Please advice and thanks you very much.....

Melanie
- 3rd December 2006, 11:21
Example run again...

c = a.highbyte + a.lowbyte

a.highbyte=$0c ' 12
a.lowbyte= $0d ' 13

c = $19 (25 Decimal)

Remember if you are adding two BYTES together, the result may be bigger than a Byte...

If a and b are hours and minutes, you can't just add them together... you must convert everything to minutes...

c=(a*60)+b

Use an external I2C EEPROM like a 24LC32 (4k) or 24LC64 (8k)for your storage (see I2CWRITE and I2CREAD commands in your PBP manual).

DragonBall_6
- 4th December 2006, 10:17
Hi all

First of all ,thanks to Melanie again.

I had planned to use the external eeprom but i have not knowledge on using.
I had gone thru the PBP manual but I still cant catch it.
Can you please guide me to the basic so that I could start it easily?
The overall of the code I will do it on my own and if i got any question then I will ask you. Is that ok?
I had planned to use the PIC16F876A due to shortage of my I/O port.
Is that the same ways using the I2Write and I2Read?????

Thanks

Melanie
- 4th December 2006, 12:01
Example... this assumes that your external EEPROM has a device address of $A0 (see your chosen EEPROM's Datasheet) and is of the 24LC32/24LC64 type). SCL is the PIC pin you are using for the I2C Clock line, SDA is the PIC pin you are using for the I2C Data line.


'
' Subroutine Writes BYTE to External EEPROM
' ------------------------------------------
SetDataExternal:
' I2CData - General BYTE variable
' I2CDeviceAddress - Hardware Device Address - BYTE variable
' I2CDataAddress - Address in EEPROM - WORD variable
I2CDeviceAddress=$A0
I2CWrite SDA,SCL,I2CDeviceAddress,I2CDataAddress,[I2CData]
Pause 10
Return

and the opposite to read...


'
' Subroutine Reads BYTE from External EEPROM
' -----------------------------------------
GetDataExternal:
' I2CData - General BYTE variable
' I2CDeviceAddress - Hardware Device Address - BYTE variable
' I2CDataAddress - Address in EEPROM - WORD variable
I2CDeviceAddress=$A0
I2CRead SDA,SCL,I2CDeviceAddress,I2CDataAddress,[I2CData]
Return

For further information lookup the I2CREAD and I2CWRITE commands in your PBP manual and compare the examples against the EEPROM Datasheet.

DragonBall_6
- 5th December 2006, 01:01
Hi Melanie

Thanks you...

Can I know do I need to erased the external eeprom (24LC32) once i write it or once I programmed it???

Which mean that I have to use I2write command to write all the data (365's sunrise times to the external eeprom)?? So I have to put the I2write command right after the all declaration and initialization.

Thanks to your basic guideline. I will try this out.

DragonBall_6
- 5th December 2006, 09:58
Hi Melanie

Can I know it is possible to use 2 interrupt in a single program as i am using PIC16F876A?

(i) TMR0 using to create 1 second elapsed time to create date and time.
(ii) TMR1 using as sending 4.32 second pulses to the stepper motor driver ucn5804B.


It is possible ??

Please advice..
Thanks you very much.

Melanie
- 5th December 2006, 11:39
The content of a new EEPROM is unpredictable, all locations should be set to $FF but this cannot be guaranteed. It is simple to bulk erase an EEPROM with your PIC programmer (always assuming your programmer is capable of handling EEPROMS).

If you write to the EEPROM, the content is retained even with the power removed.

Yes you can have as many interrupts as you want, but your program becomes more complex.