'******************************************************** '* * '* I2C PROJECT FOR USE WITH BOOST BASIC * '* * '* WRITTEN BY : PUNERJOT SINGH MANGAT * '* COUNTRY : INDIA * '* CITY : PATIALA * '* WEB PAGE : www.rackeys.com/punerjot * '* EMAIL : punerjot@rackeys.com * '* SOURCEBOOST ID : c58_4311 * '* RELEASE DATE : March 03, 2006 * '* REVISED DATE : May 24, 2006 * '* * '******************************************************** ' ' 'This project file demonstrates the use of the i2cbaslib.bas file for making a software I2C eeprom readin/writing routines 'The Pin(4) of PORTC is connected to the SCL pin of I2C eeprom 'The Pin(5) of PORTC is connected to the SDA pin of I2C eeprom 'NOTE : the pull up ressistors of 10K or 4.7K are needed both at the SDA and SCL lines ' ' Sub main() call lcd_init() 'Initialize the LCD to appropriate format call i2c_init() 'Initialize the i2c software routines call lcd_clear() 'Clears the LCD 'below is the code for reading the I2C eeprom in a random manner call lcd_putch(call i2c_read_random(3)) 'address from where the byte is to be read = 3 call lcd_putch(call i2c_read_random(4)) 'address from where the byte is to be read = 4 call lcd_putch(call i2c_read_random(5)) 'address from where the byte is to be read = 5 call lcd_putch(call i2c_read_random(6)) 'address from where the byte is to be read = 6 call lcd_putch(call i2c_read_random(7)) 'address from where the byte is to be read = 7 'below is the code for reading the I2C eeprom in a sequential manner call i2c_start_seq_read(2) 'start address from where we have to start reading the I2C eeprom call lcd_putch(call i2c_readbyte()) 'reading the byte at present possion call i2c_ack() 'sending acknowledge which moves the address poniter to next location call lcd_putch(call i2c_readbyte()) call i2c_ack() call lcd_putch(call i2c_readbyte()) call i2c_ack() call lcd_putch(call i2c_readbyte()) call i2c_ack() call lcd_putch(call i2c_readbyte()) call i2c_ack() call lcd_putch(call i2c_readbyte()) call i2c_nack() call i2c_end_seq_read() 'end of sequential read sequence 'below is the code for testing the writing to I2C eeprom call i2c_write(0, 69) 'writing E at address 0 call lcd_putch(call i2c_read_random(0)) 'reading the written byte from address 0 Do while 1 Loop End sub
Copyright © 2006 SourceBoost Technologies