PIC17C752-08/CL MICROCHIP [Microchip Technology], PIC17C752-08/CL Datasheet - Page 175

no-image

PIC17C752-08/CL

Manufacturer Part Number
PIC17C752-08/CL
Description
High-Performance 8-Bit CMOS EPROM Microcontrollers with 10-bit A/D
Manufacturer
MICROCHIP [Microchip Technology]
Datasheet
EXAMPLE 15-2: INTERFACING TO A 24LC01B SERIAL EEPROM (USING MPLAB-C17) (Cont.’d)
// Writes the byte data to 24LC01B at the specified address
void ByteWrite(static unsigned char address, static unsigned char data)
{
}
// Reads a byte of data from 24LC01B at the specified address
unsigned char ByteRead(static unsigned char address)
{
}
1998 Microchip Technology Inc.
StartI2C();
IdleI2C();
WriteI2C(CONTROL);
IdleI2C();
if (!SSPCON2bits.ACKSTAT)
{
}
IdleI2C();
StopI2C();
IdleI2C();
return;
StartI2C();
IdleI2C();
WriteI2C(CONTROL);
IdleI2C();
if (!SSPCON2bits.ACKSTAT)
{
}
return(SSPBUF);
WriteI2C(address);
IdleI2C();
if (!SSPCON2bits.ACKSTAT)
WriteI2C(address);
IdleI2C();
if (!SSPCON2bits.ACKSTAT)
{
}
WriteI2C(data);
RestartI2C();
IdleI2C();
WriteI2C(CONTROL+1);
IdleI2C();
if (!SSPCON2bits.ACKSTAT)
{
}
getcI2C();
IdleI2C();
NotAckI2C();
IdleI2C();
StopI2C();
IdleI2C();
// Send start bit
// Wait for idle condition
// Send control byte
// Wait for idle condition
// If 24LC01B ACKs
// Send control byte
// Wait for idle condition
// If 24LC01B ACKs
// Send data
// Wait for idle condition
// Send stop bit
// Wait for idle condition
// Send start bit
// Wait for idle condition
// Send control byte
// Wait for idle condition
// If the 24LC01B ACKs
// Send address
// Wait for idle condition
// If the 24LC01B ACKs
// Send restart
// Wait for idle condition
// Send control byte with R/W set
// Wait for idle condition
// If the 24LC01B ACKs
// Read a byte of data from 24LC01B
// Wait for idle condition
// Send a NACK to 24LC01B
// Wait for idle condition
// Send stop bit
// Wait for idle condition
PIC17C7XX
DS30289A-page 175

Related parts for PIC17C752-08/CL