Multiple masters communication

Hi all,

I am designing a system like a PLC where I need multiple ATmega to communicate each other, but I need more than one master as some of then needs to start the communication.

I see this is not possible over SPI. But I think for what I read that it is possible with I2C. The key thing is how can I accomplish this without having collisions or communication problems?

Thing to do is:
Case1: CPU1 wants to talk with CPU2, and starts the communication over I2C. NO PROBLEM.
Case2: CPU3 have some data to send to CPU1, tells over I2c that it has some data, and now CPU1 reads CPU3 over I2C.

It can't be done over I/O pins, not enough pins for the amount of CPU's! But it is all centralized over CPU1.
I know CPU1 can read over regular intervals all the other CPU's, but this is a lack of time, too slow and not optimal. As I am learning I want to find the right solution.

Thanks all!

I'd start reading everything on this forum related to I2C.

Nick Gammons ( very active moderator on this forum) web site has a lot of very useful information with code examples for I2C.

Then get something programmed and report back with code and detailled problem description if things don't work as expected.

Ohh...I forgot. Yes, I2C is a good way to do what you are describing. It can get tricky if bus length get too long, but then there are solutions for such problems.

Thank you so much Headroom,

So I2C is a good way to start. I asked this because maybe is there a more appropriated protocol. The communication is between pcb's, so there is no cables in between.