Eepro
Eepro
Eepro
html
1 of 4
More
Next Blog
ankitdhimancr@gmail.com
Dashboard
Sign Out
This blog provides electronic circuits specially based on PIC microcontrollers and Arduino boards
Home
Arduino Projects
PIC18F4550 Projects
PIC16F877A Projects
PIC16F84A Projects
More
Programmers
About Blog
Search :
Friday, March 27, 2015
Translate
Select Language
Translate
Powered by
TOPICS:
7 Segment (4)
Arduino (15)
DC Motors (9)
LCD (15)
LED (13)
Microcontroller (24)
MikroC (2)
PIC16F84A (11)
PIC16F877A (23)
PIC16F887 (2)
PIC18F4550 (5)
Programmer (3)
Real Time Clock (7)
A0, A1, A2: used for device addressing according to the following table:
Schematic (6)
Sensor (7)
Software (1)
Useful Web Links
http://www.arduino.cc/
http://www.mikroe.com/
About Me
Popular Posts:
PIC16F877A Projects
PIC16F877A Projects
PIC16F877A Projects
with MikroC Codes List
of microchip
PIC16F877A Projects
done on this blog:
Interfa...
Cd-Rom Brushless DC
Motor Control
Sensored BLDC Motor
Control Using
PIC16F877A Sensored
BLDC Motor Control
This topic shows how
to control sensored
brushless dc motor....
EEPROM (1)
Proteus (5)
Archive:
Cd-Rom 3 phase
Sensored BLDC Motor
Arduino Controller
Sensored BLDC Motor
Control BLDC
(brushless dc) motors
are three phase dc
motors, unlike the
simple dc motors the
bldc motors are more
...
For example in general when A0, A1, A2 connected to ground the device address becomes:
(for 24C08A A0 & A1 can be disconnected).
Write data to EEPROM:
Start I2C protocol,
Send EEPROM write mode address,
Send byte address,
Send data,
Stop the I2C protocol.
The 24C08A has 1024 bytes of memory organized as 4 blocks of 256 bytes.
Assume A2 connected to ground, the addressing of our eeprom bcomes as shown on the
following table:
Electron Note
205
P1 and P0 are called the page address which used to to select one of the four pages of 24C08A
EEPROM.
So, the complete process of writing byte is shown below:
11/5/2015 6:57 PM
2 of 4
void write_data(char
I2C1_Start();
I2C1_Wr(0xA0);
I2C1_Wr(address);
I2C1_Wr(data_);
I2C1_Stop();
}
On this application I am going to write 4 different values at different addresses then read these
values and display it on 1602 LCD display.
The values are: (decimal)
7 at address 10, 141 at address 320, 255 at address 680 and 224 at address 1010.
The LCD displays as shown on the previous picture.
MiKroC code:
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
char a ;
void write_data(unsigned address, char data_){
11/5/2015 6:57 PM
3 of 4
char device_address;
device_address = 0xA0;
if(address > 767) {address -= 768;
device_address = 0xA6;
goto write;}
if(address > 511) {address -= 512;
device_address = 0xA4;
goto write;}
if(address > 255) {address -= 256;
device_address = 0xA2;
goto write;}
write:
I2C1_Start();
I2C1_Wr(device_address);
I2C1_Wr(address);
I2C1_Wr(data_);
I2C1_Stop();
}
void read_data(unsigned address){
char device_address;
device_address = 0xA0;
if(address > 767) {address -= 768;
device_address = 0xA6;
goto read;}
if(address > 511) {address -= 512;
device_address = 0xA4;
goto read;}
if(address > 255) {address -= 256;
device_address = 0xA2;
goto read;}
read:
I2C1_Start();
// start I2C signal
I2C1_Wr(device_address);
I2C1_Wr(address);
I2C1_Repeated_Start();
I2C1_Wr(device_address + 1);
a = I2C1_Rd(0);
I2C1_Stop();
}
void main(){
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
// cursor off
Lcd_Cmd(_LCD_CLEAR);
// clear LCD
I2C1_Init(100000); // initialize I2C protocol at 100KHz
delay_ms(20);
write_data(10, 0x07);
delay_ms(20);
write_data(320, 0x8D);
delay_ms(20);
write_data(680, 0xFF);
delay_ms(20);
write_data(1010, 0xE0);
delay_ms(20);
read_data(10);
Lcd_Chr(1, 2, (a/100) + 48);
Lcd_Chr(1, 3, ((a/10)%10) + 48);
Lcd_Chr(1, 4, (a % 10) + 48);
read_data(320);
Lcd_Chr(1, 8, (a/100) + 48);
Lcd_Chr(1, 9, ((a/10)%10) + 48);
Lcd_Chr(1, 10, (a % 10) + 48);
read_data(680);
Lcd_Chr(2, 2, (a/100) + 48);
Lcd_Chr(2, 3, ((a/10)%10) + 48);
Lcd_Chr(2, 4, (a % 10) + 48);
read_data(1010);
Lcd_Chr(2, 8, (a/100) + 48);
Lcd_Chr(2, 9, ((a/10)%10) + 48);
Lcd_Chr(2, 10, (a % 10) + 48);
}
while(1);
// Endless loop
11/5/2015 6:57 PM
4 of 4
3 comments
Add a comment as Ankit Dhiman
Top comments
Electron Note shared this via Google+ 7 months ago - Shared publicly
+2
3
Reply
Reply
Electron Note shared this via Google+ 4 months ago - Shared publicly
+2
3
Reply
Newer Post
Home
Older Post
11/5/2015 6:57 PM