PDA

View Full Version : PIC as I2C Slave



Mainul
- 5th January 2013, 05:51
Happy new year to everybody.

This is my first post here. Whenever I had a problem, a little search in this forum presented me with very good solution posted by other members, who seemed to be experts in their respective fields.

I am planning to connect several small PIC Microcontrollers on an I2C bus. One Microcontroller (May be 16F877A) will be master and scan all the slaves one by one for changes (button press or something like that). The slave will send one data byte only when Master request data on its particular address, will remain silent for rest of the scanning period. The search will be repeated after the last slave is scanned.

I have designed several projects where the slave is an 24CXXX( EEPROM) or DS1307(RTC), which is not very difficult. They are working fine. But I am finding difficulty in thinking of a PIC as slave, assigning control and unique address bytes to each slave.

I would highly appreciate any help (code examples etc.) from those experts in this forum.

Mainul

mackrackit
- 5th January 2013, 09:04
Have you seen the articles here?
http://www.picbasic.co.uk/forum/content.php?r=69

Mainul
- 5th January 2013, 11:17
mackrackit

Thanks a lot for such a prompt reply, I shall give it a try. I was certain to have something useful from here, that's why I love this forum so much.

The 18F chips are still difficult for me to handle, but I shall play with 16F877A and 16F88 chips. Well, how many slaves can be handled at a time on a single I2C bus? 10, 100 or more?

Mainul

mackrackit
- 5th January 2013, 11:54
Do not be afraid of the 18s, once you get past the setup they are not that much different than a 16. If you need help getting an 18F configured someone here will be able to help.

As for how many I2C's on I bus I am not sure, I should know... (see avatar) :eek:

Mainul
- 5th January 2013, 13:23
I was studying the datasheet of 16F88. The ‘SSP I2C Mode Operation’ section (10.3, page 94) says that SSP module can be configured for 7 bit or 10 bit addressing. So I guess in 7 bit addressing mode 128 unique addresses can be generated, similarly 1024 addresses in 10 bit mode. Is it really possible to connect 128 (or even 1024) 16F88 slaves in a single I2C bus? Seems to be very interesting!

I have a plan to jump into 18F series soon, shall come back with lot more problems.