# Data send only in MCU based I2C Slave

I want to know that is it possible that a Slave I2C device which is a 32-bit MCU, for example STM32F407, I write its I2C data send function and send data through it after every 1 sec? I am asking this because my understanding is that I2C is a command-response protocol. A salve will not send data unless it will receive a command to do so. So for the case of fixed I2C based sensor chips this logic or protocol is embedded in the chip silicon. It's state machine will not send data unless it gets a command first.

But in the case of an MCU in which I2C is a peripheral and it is configurable and programmable.. will it be possible to call the I2C_Data_Send() library function in my test program that will send for example 1-byte of test data over and over again?

So essentially what I want to know is that when an I2C Slave is a peripheral in an MCU then does its SEND and RECEIVE digital logics are implemented independent from each other in the hardware or they are logically tied together? If it's the later case then obviously I will not be able to invoke the SEND_DATA logic without first receiving the COMMAND from a I2C Master. But if its the first case and SEND and RECEIVE logics are independent then I can start an I2C_SEND_DATA() case anytime from my firmware (specially at the time of testing the setup to see if my data sending logic is working or not).

Overall I will have single Slave device (an I2C MCU) and no Master. I want to see if I can make to to send data without any master giving it a command or ACK/NACK or START/STOP signal. I will be looking at the output on an oscilloscope by pulling-up the SCL, SDA lines of the Slave device.

Overall I will have single Slave device (an I2C MCU) and no Master. I want to see if I can make to to send data without any master giving it a command or ACK/NACK or START/STOP signal.

That's not possible for an I2C Slave. Any device which did that, wouldn't be I2C-compliant.

From this comment:

I want to do this only for my test setup. I will see the data on oscilloscope to confirm that my I2C device is sending the data.

So let's approach things differently:

• Do you want to see what data the MCU-acting-as-I2C-slave has got, without using its I2C interface?

If so, then use a different interface on the MCU-acting-as-I2C-slave (e.g. UART, or even bit-banged on a single GPIO pin) to send the data to whatever you want (oscilloscope, logic analyser).

Or...

• Do you want to test the ability of the MCU-acting-as-I2C-slave to send data using I2C, but without having to program another MCU as the I2C Master for that testing?

If so, consider something like the Dangerous Prototypes Bus Pirate device. This connects via USB to a PC and can be easily programmed (and scripted) to be a simple I2C Master (example). I usually use one of these, when I start working with a new I2C Slave device.

It seems your asking if you MCU can (also) be a Master on the I2C bus.

Of course, there can be multiple Master devices on the I2C bus.

But then your MCU needs to be paying attention to the bus, so it does not try to send while another Master is sending

• Not exactly a MASTER. I want to keep it as a SLAVE but fool it to send data even when it has not received any command from any MASTER. I will be doing it only for my test setup. So this SLAVE MCU device will be all alone and not connected with any other MASTER or SLAVEs on the bus. – alt-rose Nov 13 '19 at 5:10
• a I2C slave is totally passive. It only reacts when it has been 'kicked' via a command to its' id address, with a register selection and and the read bit set – user3629249 Nov 13 '19 at 5:21
• Without a master waiting for the response who will receive the data? Slaves don't send an address. – the busybee Nov 13 '19 at 8:31
• You are right, there will be no one on the bus to receive the data. I want to do this only for my test setup. I will see the data on oscilloscope to confirm that my I2C device is sending the data. – alt-rose Nov 13 '19 at 8:49