1
votes

Is there any way to set the SDA and SCL pin of the I2C1 connection of the STM32 to low or high signal?

I use a security chip and I have to send a wake condition, with the following condition:

if SDA is held low for a period of greater than 60us, the device will exit low power mode and after a delay of 1500us, it will be ready to receive I2C commands.

I've already tried to toggle the actual pin with HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);, but this isn't working.

I've configured my project with STM32CubeMX.

Thanks for your help.

3
What chip is it? Are there no instructions for how to achieve this from the I2C master side? It does seem you should just do this before handing control of the GPIO pins over to the STM32's I2C peripheral. - unwind
It's a microchip atecc508a. I didn't find any instructions of how to set a sda or scl pin to low or high state. I should mention, that I use a library to access chip functionality. It's called cryptoauthlib and there I have to create my own hal implementation to interact with the atecc508a. - Habebit
At I2C standard speed, 100kHz, 60 µs are 6 pulses. So technically, you could send a 0x00 as command to achieve this. - Andreas Duering
Not all STM32 devices are necessarily alike - you should specify exact device. - Clifford
If the pin B9 is already configured to its alternate SDA function, the GPIO toggle will not work. You would have to dynamically reconfigure the pin, which is possible if it has not been locked. - Clifford

3 Answers

1
votes

In I2C, the START condition requires a High to Low transition, if you then send a dummy address 0, a NACK will be generated (or rather the lack of any response will be interpreted as a NACK). In a normal transaction, the software would respond to the NACK by generating a repeated START or a STOP condition, however this must be done in software, so all you have to do is nothing for 1.5ms. Thereafter you can generate the START with the device's actual address, and if the device is running it will generate an ACK.

I am not familiar with the HAL library driver, and frankly the documentation is abysmal, but it is possible that it does not give you the necessary control, and you will have to access the I2C peripheral at the register level for at least this procedure. You might try a zero-length I2C_MasterRequestWrite() call to address zero followed by a delay. An oscilloscope would be useful here to ensure the expected signal timing is being generated.

0
votes

When you initialize I2C, GPIO pins mode is set to ALTERNATE MODE,so writing HAL commands won't work on it.

Using normal HAL libraries won't help you in this. You have to configure I2C protocol on your own using stm32 registers.

0
votes

I recommend that the ownaddress of the slave address using the device of the using I2C channel sets like the below code.

I2C_InitStructure.I2C_OwnAddress1 = 0x30; // the unique slave address of the deviecs

because the master could be send the broadcast operation not the unique operation.