MB2146-450-E Setup Guide
Chapter 4 Sample Code Manual
MCU-AN-500072-E-10 – Page
33
4.2.5 I2C .c
In this function, we should initialize I2C status and use SCL and SDA to send data to master
device and receive data from slave device.
Following table describes the I2C library:
Function Name
Description
unsigned char RD_I2C( unsigned char
Main_Addr, unsigned char Sub_Addr )
Read data from Sub_Addr
void Write_I2C_Proc(unsigned char
MainAddr, unsigned char SubAddr, unsigned
char I2Cdata)
Write data I2Cdata to SubAddr
Following table describes how to use these functions.
Example
Type
Operation
Return
Read data
RD_I2C(0xa0,0x01);
Read data from EEPROM sub
address 0x01
Write data to
EEPROM
Write_I2C_Proc(0xa0,0x01,0x25); Write 0x25 to EEPROM sub
address 0x01
4.2.6 LCD .c
In this function, we should initialize LCD register and drive LCD by sending different data to
SEG00…SEG31
Following table describes the LCD library:
Function Name
Description
void Init_LCD(void)
Initializes LCD module
void LCD_Clear(void)
Clear LCD display
void LCD_LigON_NUM(unsigned char Num,
unsigned char Dat)
Drive LCD Num to display number Dat
Following table describes how to use these functions.
Example
Type
Operation
Return
Display LCD
LCD_LigON_NUM(0x02,0x06);
Drive LED 2 to display number 6