PDA

View Full Version : need resources on Microwire 3 Wire interface eeprom control



EDWARD
- 3rd June 2005, 13:58
i have a pic16f73 at 4 mhz. i have a microchip 93c46 eeprom connected to the pic. i am tring to write variables to the eeprom before powerdown and then recall them at power up. i cant find any webpages or anything that even shw what commands to use. imm pretty sure i can't use I2CREAD commands. i have a picture of my layout. i just need to get pointed in the right direction. i think i need the microwire 3 wire interface, is this right?

I only have like 6, single byte sized variables i need saved, and they are only updated if they are changed and then pic is shutdown, and they arent changed that often.

also, does the 16f73 have onboard eeprom? and do i need to define stuff before i can use it? i have looked mad hard at the datasheets.

Bruce
- 3rd June 2005, 16:01
You'll need to use Shiftin/Shiftout for SPI EEPROMs. Here's an example.
http://www.microengineeringlabs.com/resources/samples/x1/pbp/spix.bas

mister_e
- 3rd June 2005, 18:46
if you want to use the internal EEPROM use READ and WRITE command. You don't need to declare anything else. Everything is explain in the PBP manual.

EDWARD
- 4th June 2005, 03:22
thank for the replys.

i have tried using the read command and the write command. it gives me errors in my program at the compiing stage. it says something like undefined symbol 'WREN" or undefined symbol 'pgd' or somehing theres about 6 in all.

i am using the 16f73 and i think that the data sheet for it says that there is non-volatile eeprom memoery onboard that i can use. but not 100% sure if my pic has this memory.

i will look into the shiftin commands. thanks

i am simply trying to store about 6, byte sized variables in all. the variables are to be saved at power down and loaded at power up.

mister_e
- 4th June 2005, 10:41
i didn't read the datasheet but i'll trust you on the fact it doesn't have any internal EEPROM. In this case, you can still skip the external EEPROM idea and use the code space to save your variables.

see this thread from Melanie (http://www.picbasic.co.uk/forum/showthread.php?t=137&highlight=playground)

EDWARD
- 7th June 2005, 19:39
thanks for the help so far. sry i got back to this so late but i haven't yet solved this problem. since my boards are already have an external eeprom (93c46), i have decided to use it. i just cant grasp how the eeprom works and need help understanding some things.

1. Does the eeprom have command instructions seperate from data instructions?

2. how does the informatiopn flow? are there byte sized instruction signals that tell the eeprom to get ready for data then it sends the data byte?

3. or is the instrunction on the msb of a word or something? or a bit in the sequence?

4. do i need to define a port speed?

if you dont want to answer these can you suggest any references that have an example of writing and reading from these external eeproms?

i have a pic of how my eeprom is on the pcb on a post by me, in this topic.

thanks!

oh yeah, i really would like an example that doesnt have lcd stuff in it

EDWARD
- 10th June 2005, 07:31
I am trying to write just 3, byte sized variables to the external eeprom and recall them at power up.

heres the data sheet for my eeprom:
http://www.datasheetarchive.com/search.php?search=93c46&sType=part

what should my trisB and TRISC be?? are they all outputs except for D0 (data out on epprom)



CS - PORTB.1
CLK - PORTB.2
D1 - PORTC.6
D0 - PORTC.7

this is what i have so far:


include "modedefs.bas"

D var byte
T var byte
ED var byte

addr var word
B0 var byte


eeread:

for addr = 0 to 2 'eeprom address

PORTB.1 = 1 'cs = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$03, addr.byte1, addr.byte0]
PORTB.1 = 0 'cs = 0

PAUSE 1

PORTB.1 = 1
Shiftin PORTC.7, PORTB.2, MSBPRE, [B0]
PORTB.1 = 0

if addr = 0 then
d = B0
endif

if addr = 1 then
t = B0
endif

if addr = 2 then
ED = B0
endif

next addr
return







eewrite:
for addr = 0 to 2

if addr = 0 then
B0 = D
endif

if addr = 1 then
B0 = T
endif

if addr = 2 then
B0 = ED
endif

PORTB.1 = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$06]
PORTB.1 = 0

PAUSE 1

PORTB.1 = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$02, addr.byte1, addr.byte0, B0]
PORTB.1 = 0

next addr
return


this is not all the code, but i want "encapsulated" SUBs that will take care of the reading and writing to the eeprom. so that is all i have shown. :)