cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get a device to work on I2C on STM32F4

denix8
Associate II
Posted on November 01, 2016 at 13:19

Hi!

In the past, I used Arduino Mega and Uno for some project of mine that required an OLED screen based on

http://www.thebackshed.com/forum/uploads/jman/2014-12-21_042323_IMG_1JPG

driver and Real Time Clock module (

http://docs.macetech.com/doku.php/chronodot

). Both work on I2C interface and worked just fine on Arduino. Chronodot uses Stephanie Maks'

https://github.com/Stephanie-Maks/Arduino-Chronodot

and SSD1306 used

https://github.com/olikraus/u8glib

. I needed more CPU power and memory, therefore I bought STM32F4 I rewrote Stephanie Maks' library to work with Tilen Majerle's

https://stm32f4-discovery.net/2014/05/library-09-i2c-for-stm32f4xx/

for STM32F407, which is also used by SSD1306 through

https://stm32f4-discovery.net/2015/05/library-61-ssd1306-oled-i2c-lcd-for-stm32f4xx/

. The SSD1306 screen worked without a problem on any I2C (I2C1, I2C2, I2C3), but I could not get Chronodot to work. I tried different I2Cx and pin packs, but still nothing. I connected it back to Arduino and it works without a problem. Yes, I could have made a mistake when rewriting the library, BUT it doesnt even pass the basic test:


Chronodot rtc;

TM_I2C_Init(I2C1, TM_I2C_PinsPack_1, 400000); 
// Configure I2C for RTC

rtc.begin();

/* Check if RTC connected to I2C */

if
(!TM_I2C_IsDeviceConnected(I2C1, CHRONODOT_ADDRESS))

{

/* Return false */

return
0;

}

Is it possible that different I2C is used on Arduino and SSD1306 screen just includes both versions? Maybe some ACK or something? I do not fully understant everything that can change in this protocol so I can't speculate much what could be wrong. I ask for your assistance please. Thank you! #i2c-ssd1306-stm32f4-chronodot
2 REPLIES 2
Santoli.Massimo
Associate II
Posted on November 01, 2016 at 22:23

Hi,

I guess you double checked all connections and HW wise everything is correct ( for example I read the the Chronodot doesn't have pull up resistors on board which are necessary for the I2C, so I assume you have them on the STM32F4 board... )

Your code looks correct, my only hint is to verify the Slave Address of the Chronodot.

On the Arduino you use 0x68 ( just the 7 bits ) on TM library ( and in general STM32 I2C libraries ) you must specify the full 8 bits, so the address should be 0xD0..

Massimo

denix8
Associate II
Posted on November 02, 2016 at 11:13

Thank you for response!

Yes, that was exactly it, 8-bit address instead of 7-bit. I even read an article on addresses and I couldn't figure out that it was wrong. Thank you so much!