ࡱ>  Root EntryqQ"MAIN RSCOMPSTG1L&>L"L"CONTENTS  WG _extentxR WG _extentyport01bit0port10bit1port23bit2port32bit3port45bit4port54bit5"yTlcdsize WG _extentx@ WG _extenRSCOMPSTG2MNgAM(fXL"L"CONTENTStyport01bit0 6>bsmbus ,bslew 0$bcustombaude΂lbaud +U bsoftwareuxnportmW nscl` nsda 5D(lclockspeed, *[ඈbshowhex RSComponent LCDDisplayI2C16f877a,0x2007,0x3f3a H RSFlowlineMainXXKT RSStartStopCmdMainRSMacroCallCmdInitialise the LCDStart LCDDisplay(0)0Initialise the IC MI2C_InitI2C(0)0 RSCommentCmdWThe mode variable configures the IC EEPROM program to either read or write the memoryRSCalculationCmdConfigure mode Calculation0mode aIf Mode = 0 then the characters "Hi" will be written to the first two bytes of the EEPROM memory. RSDecisionCmdWrite "Hi" to the IC EEPROMmode = 0MainXXMainMainMainXXMain Write Macro Write_I2C0 Main Basic overview of a IC Write transaction 1) Start transaction 2) Send device address with read/write bit = 0 3) Send internal EEPROM address MSB 4) Send internal EEPROM address LSB 5) Send n data bytes to be written 6) Stop transactionMain lIf Mode = 1 then the first two bytes of the EEPROM memory will be read and be printed out to the LCD displayRead the IC EEPROMmode = 1MainXXMainMainMainXXMain Read MacroRead_I2C0 <Main Basic overview of a IC Read transaction 1) Start transaction 2) Send device address with read/write bit = 0 3) Send internal EEPROM address MSB 4) Send internal EEPROM address LSB 5) Send a restart command 6) Send device address with read/write bit = 1 5) Read n data bytes from the memory 6) Stop transactionMainMain Write_I2CXXKi  Write_I2CStart IC Transaction MI2C_StartI2C(0)0Device Address + Write bitMI2C_Transmit_ByteI2C(0) RSOperand0xA0RetVal Print ACK - 0 PrintNumber LCDDisplay(0)'RetVal0Print out a comma PrintASCII LCDDisplay(0)'","0Send Internal Address 1MI2C_Transmit_ByteI2C(0)'0RetVal Print ACK - 0 PrintNumber LCDDisplay(0)'RetVal0Print out a comma PrintASCII LCDDisplay(0)'","0Send Internal Address 0MI2C_Transmit_ByteI2C(0)'0RetVal Print ACK - 0 PrintNumber LCDDisplay(0)'RetVal0Print out a comma PrintASCII LCDDisplay(0)'","0Send "H"MI2C_Transmit_ByteI2C(0)'"H"RetVal Print ACK - 0 PrintNumber LCDDisplay(0)'RetVal0Print out a comma PrintASCII LCDDisplay(0)'","0Send "i"MI2C_Transmit_ByteI2C(0)'"i"RetVal Print ACK - 0 PrintNumber LCDDisplay(0)'RetVal0Print out a comma PrintASCII LCDDisplay(0)'","0Stop IC Transaction MI2C_StopI2C(0)0 Write_I2CRead_I2CXXK b Read_I2CStart IC Transaction MI2C_StartI2C(0)0Device Address + Read bitMI2C_Transmit_ByteI2C(0)'0xA00Send Internal Address 1MI2C_Transmit_ByteI2C(0)'00Send Internal Address 0MI2C_Transmit_ByteI2C(0)'00Restart IC to perform the read MI2C_RestartI2C(0)0Read From Device CommandMI2C_Transmit_ByteI2C(0)'0xA10Read Byte at location 0MI2C_Receive_ByteI2C(0)'0RetValPrint out the byte to the LCD PrintASCII LCDDisplay(0)'RetVal0Read byte at location 1MI2C_Receive_ByteI2C(0)'1RetValPrint out the byte to the LCD PrintASCII LCDDisplay(0)'RetVal0Stop IC Transaction MI2C_StopI2C(0)0Read_I2CRETVALVariableRetValMODE]mode