
VMX51C1020
_________________________________________________________________________________________________
www.ramtron.com
page 55 of 80
Errata:
The VMX1020 I
2
C Interface has a critical timing
issue when the device is configured as a Slave
and transmits multiple data bytes. Single byte
transmission in slave mode is not effected.
The condition arises if the Master device
releases the SDA line at the same time it brings
the SCL line low for the Acknowledge phase.
In order for the VMX1020 I
2
C Slave transmission
to work properly for multiple bytes, the Master
device MUST release the SDA line AFTER the
SCL negative edge.
For this reason it is not possible to have a
VMX1020 device configured as an I
2
C Master
and VMX1020 devices configured as I
2
C Slaves
on the same I
2
C bus. Unless data transmitted
from VMX1020 I
2
C Slaves to the I
2
C Master is
done one byte at a time.
I
2
C EEPROM Interface Example
Program
The following provides an example program
using the VMX51C1020 I
2
C interface for
performing read and write operations to an
externally connected EEPROM device.
#pragma SMALL
#include <vmixreg.h>
// --- Function prototypes
unsigned char eeread(idata unsigned char, idata unsigned char);
void eewrite(idata unsigned char, idata unsigned char, unsigned char);
// - Global variables
idata unsigned char
irqcptr=0x00;
sbit I2C_TX_EMPTY = USERFLAGS^0;
sbit I2C_RX_AVAIL = USERFLAGS^1;
sbit I2C_IS_IDLE = USERFLAGS^3;
sbit I2C_NO_ACK = USERFLAGS^6;
//-------------------------------------------------------------------------------//
// MAIN FUNCTION //
//------------------------------------------------------------------------------//
void main (void){
unsigned char x=0;
DIGPWREN = 0x13;
//Enable the I2C peripheral
//*** configure I2C Speed.
I2CCLKCTRL = 0x013;
//…To about 100KHZ...
//*** Configure the interrupts
IEN0 |= 0x81;
//Enable Ext INT0 interrupt + main
//*** infinite loop waiting for ext IRQ
while(1){
};
}// End of main()...
//-------------------------------------------------------------------------------//
// EXT INT0 interrupt
//
// When the External interrupt 0 is triggered read and write
// operations are performed on the EEPROM
//-------------------------------------------------------------------------------//
void int_ext_0 (void) interrupt 0 {
// Local variables declaration
idata unsigned char eedata;
idata unsigned char adrsh =0;
idata unsigned char adrsl =0;
idata int adrs =0;
//
IEN0 &= 0x7F;
//disable ext0 interrupt
//(Masked for debugger compatibility)
//Write irqcptr into the EEPROM at adrs 0x0100
eewrite( 0x01,0x00,irqcptr);
irqcptr = irqcptr + 1;
//Increment the Interrupt counter
//Perform an EEPROM read at address 0x100
eedata = eeread(0x01, 0x00);
delay1ms(100);
//Debo delay for the switch on INT0
//
IEN0 = 0x81;
// enable all interrupts + int_0 (Removed
//for debugger compatibility)
}// end of EXT INT 0
//---------------------------------------------------------------------------------//
// INDIVIDUALS FUNCTIONS //
//--------------------------------------------------------------------------------//
//-----------------------------------------------------------------//
// EEREAD - EEPROM Random Read //
//----------------------------------------------------------------//
unsigned char eeread(idata unsigned char adrsh, idata unsigned char adrsl)
{
idata unsigned char x=0;
idata unsigned char readvalue=0;