|
by
George Martin
Start
The Basics Getting
the Routine Down Debugging Your Reads
and Writes Sources
GETTING THE ROUTINE DOWN
At a quick glance, it's encouraging to
be able to write just a few routines to manage the device. Table 1
extracts some of the routines developed in EEmem.c.
Table 1All
it takes is a few routines to manage Microchips 24C32P.
Download EEmem.c to see how Ive implemented the routines into my code.
|
|
Function
|
Prototype
|
|
|
|
|
Start an EE
transfer
|
void EE_start(void)
|
|
Stop an EE transfer
|
void EE_stop(void)
|
|
Read the acknowledge
|
char read_ack(void)
|
|
Write an EE
bit
|
void wr_EEbit(char
b)
|
|
Read an EE bit
|
char rd_EEbit(void)
|
|
Read a character
|
char EEread_char(int
i)
|
|
Write a character
|
void EEwrite_char(int
i, char c)
|
These are basic bit operations, which can be built into larger functions.
If you check out the datasheet (www.microchip.com), there are some timing requirements to consider.
Clock high (min): 4000 ns
Clock low (min): 4700 ns
Output valid from clock (max):
3500 ns
Bus free time (min): 4700
ns
The EE memory I'm writing about has a
vintage 1995 datasheet. The microprocessor I used is an 80C196, operating
at about 10 MHz. As you can see in the code, I don't have to worry
about going too fast for the device. Because 1995 is ancient history
in today's world of technology, check and double-check your datasheets.
I didn't attempt to streamline these
routines in any way. For my project, the EE memory's reads and writes
were so infrequent that it wasn't necessary. Also, I reserved a place
for a delay routine that wasnt needed since the microprocessor
did not exceed the timing requirements of the EE device.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ęCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |