I2C for external EEPROM

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

I2C for external EEPROM

Post by pilou8830 »

Hello, how to connect an EEPROM 24C256N on PIC16F877 ?
Pines of the EEPROM 1 = A0, A1 = 2, 3 = NC, 4 = GND, 5 = SDA = SCL 6, 7 = WP, 8 = VCC.
I see on the PIC16F877 pin 18 = RC3 - SCL and pin 23 = RC4 - SDA.
But when I look in C compiling, so it is used portb???
How to use the PORTC? Also when connecting the inputs A0 and A1 of the EEPROM for the example program works (I2C_EEPROM_Example.fcf)?
Flowcode V3
thank you

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: I2C for external EEPROM

Post by Sean »

The I2C component can be configured to use either the hardware MSSP in the target device, or use software routines to transmit and receive data.

The default hardware option automatically uses the SDA and SCL pins appropriate for the target device.

The software option can be allocated to any spare pins. Software port and pin definitions are always included in the C code, even if they are not being used.

The A0 and A1 pins form the hardware selectable part of the device address that must be transmitted by the I2C component (see the device data sheet). They are usually connected to the required logic levels on the pcb. Connecting both to 0V is common if this feature is not required.

The WP (Write Protect) pin can be controlled by a microcontroller output and used as a data protection feature, or disabled by connecting it to the appropriate logic level on the pcb.

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM

Post by pilou8830 »

Thank you for this clarification. A bit difficult to understand, but I'm progressing.
I made the mounting "PIC_EEPROM" Flowcode and tested with some adjustments. The LCD displays only "0,0,0,0,0," and not "0,0,0,0,0, Hi"
"Hi" is given a place in the EEPROM and get to see it. :roll:
I would show you my plan and program requirements of Flowcode but how to attach a picture? :oops:
Thank you

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: I2C for external EEPROM

Post by medelec35 »

pilou8830 wrote: but how to attach a picture? :oops:
Thank you
To upload a file to this forum, Click 'POSTREPLY' and type message as you normally would do.
then
Click Upload attachment tab
Click 'Browse', then a new window will appear.
Within that window Browse to your picture file
Click 'Add the file'
then click 'Submit'
Note: You will not be able to send bitmaps and the max file size you can send is 256K.
So you can do the following:
If you have windows xp, Vista Or windows7 the Paint program will convert bitmap to jpeg.
If you do a screen shot (just press 'Prt Scrn' , you can then open paint, edit, crop etc then save as jpeg.
Alternatively a great freeware package that will not only save as jpeg, but will reduce picture size, crop and tons of other features is called FSViewer see:
http://www.faststone.org/FSViewerDetail.htm
Martin

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM

Post by pilou8830 »

Thank you for responding so quickly. Here are pictures of mounting a PIC and EEPROM on the program Flowcode V3 with I2C.
Y there mistakes?
On my LCD it displays "0,0,0,0,0, **"
Note: * = bizare characters :cry:

thank you
Attachments
parameters and display
parameters and display
Flowcode V3 I2C.jpg (21.63 KiB) Viewed 18200 times
diagram EEPROM TO PIC16F877
diagram EEPROM TO PIC16F877
PIC_EEPROMbis.jpg (212.18 KiB) Viewed 18200 times

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: I2C for external EEPROM

Post by saschech@gmx.de »

Hello
The chip is write protect.
Have a look:

http://pdf1.alldatasheet.com/datasheet- ... 4C256.html

Regards wolfgang

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM

Post by pilou8830 »

Yes! I misspoke when I did the diagram to show you my setup. Which were correct, WP to 0V (GND).
Problem: why my data instead of becoming 255.255 72.103 72pour which H i and 103 for either "Hi"? Flowcode in my LCD and two odd characters (see attached images)
Attachments
my lcd
my lcd
My LCD.jpg (84.54 KiB) Viewed 18192 times
flowcode
flowcode
Flowcode V3 I2C.jpg (21.63 KiB) Viewed 18192 times
diagram ok
diagram ok
PIC_EEPROM.jpg (58.44 KiB) Viewed 18192 times

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: I2C for external EEPROM

Post by saschech@gmx.de »

Hello

In simulation you must giv the ee-prom value into the queue.
Attachments
value in queue.gif
(91.56 KiB) Downloaded 6872 times

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: I2C for external EEPROM

Post by Dan81 »

Hello

Lines SCL and SDA need pull up (4.7k), (they are not drawn on your schematic).

For debugging : Instead of using "Print Ascii" macro you can use "Print number"and see the received values.

Post your file, it will be easier for us to help you.

Daniel

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM

Post by pilou8830 »

For Sashech : I have version V3.2 of Flowcode I hope it's good too.
For Dan81 : I added the two resistors. It's just like here? see attachment PIC_EEPROM.jpg
et je joins le fichier I2C_EEPROM_example.fcf
What is a queue? 88,77,66,55 is data or address what is here??see the program Sashech.
in my example program : In I2C DATA component where the start address and end.
Here we start at the first address? 00 and there are two data 72 and 105 for "H" and "i". As put in the queue? I do not understand.
help

thank you both.
Attachments
I2C_EEPROM_Example.fcf
PROGAM I2C_EEPROM_example.fcf
(8 KiB) Downloaded 849 times
DIAGRAM PIC_EEPROM
DIAGRAM PIC_EEPROM
PIC_EEPROM.jpg (62.78 KiB) Viewed 18178 times

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: I2C for external EEPROM

Post by saschech@gmx.de »

Hello pilou8830
queue = in german schlange....
If jou simulate write to the ee-prom , it do nothing real,only it show data in the " data window ".
The code read in the " queue window " ...if there are not data (you must input it ;click + ...) jou have a mitch match ...
Attachments
translate.gif
(64.32 KiB) Downloaded 6855 times

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM

Post by pilou8830 »

Saschech agree, is that the queue window is only used for simulation?
:oops:

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: I2C for external EEPROM

Post by saschech@gmx.de »

yes,thee 2 windows simulate the ee-prom (correctly the data`s on the i2c bus)

For test your real hardware yu must connect at least led`s or better a lcd display.

Regards Wolfgang

pilou8830
Flowcode V4 User
Posts: 58
Joined: Mon Aug 16, 2010 12:52 am
Been thanked: 1 time
Contact:

Re: I2C for external EEPROM RESOLVED

Post by pilou8830 »

After changing the port (port A to port B) Port B default because Flowcode outputs are real!
And after loading the SLC and SDA pins with resistors of 4.7 k everything works!
Thank you Thank you Thank you :P

Post Reply