Nucleo STM32F401RE I2C

Tags: i2c, nucleo, st, embedded

I've decided to take up a challenge and learn more about the I2C protocol. I am not going to go into detail about the I2C, there are plenty (13 million) places on the internet that already explain how it works and more. You read about it here and here

At the same time I wanted to practise with Keil environment as well as well learn a bit more about the STM32F401 MCU. ST seem to have stopped supporting Standard Libraries and have been working on HAL implementation with their ST32CubeMX application that can generate configuration and project files between their STM32Fx controllers. That's neat, because you can test your user code between a variety of ST's controllers just by re-generating configration/setup code for each specific MCU with less scrambling between MCU datasheets.

For my first exercise I've got a few 24LC256 EEPROM chips (just in case I burn some up) and got to wiring it to my Nucleo. Typically I2C requires a pull-up resistor on SDA and SCL lines, however whilst doing my reading I found that the internal pull-up resistors on Nucleo could be used just as good. Also reading Arduino I2C related forums also mentioned that internal pull-up resistors are good.

Got my Keil project generated and ready to get into HAL's I2C library. I have to say, its much easier when there is a doc [PDF] file arround. Initially I only wanted just to see if the device is ready. However, that did not work. Everything I tried just kept returning an error or busy code. Whipping through 24LC256's datasheet does not show any special requirements to talk to it. 

It took me some time until I decided to stop debugging my 5 line code and started getting into the HAL's I2C library itself. To speed my debugging, I've commented out all loops that returned either a TIMEOUT or ERROR codes and the comms started working. Hmm... that's strange, how can that be? What have I missed in the datasheet? Reading a little more into the documentation I've noticed that the chip does not send ACK whilst doing processing. Could that be it?

I'll have to investigate more.

Recent Posts

  • My new mechanical keyboard

    I had a lot of fun building my custom ErgoDox keyboard and used it for a over 6 months until I came across a Ducky Shine keyboard. I was able to gather  £100 to get it ordered and what can … more

  • Nucleo STM32F401RE I2C

    Tags: i2c, nucleo, st, embedded

    I've decided to take up a challenge and learn more about the I2C protocol. I am not going to go into detail about the I2C, there are plenty (13 million) places on the internet that already explain … more

  • Deck build - Decisions decisions

    Tags: diy, deck, garden

    Whilst I've got the shape worked out, I was debating if I should tie it to the house using a ledger board or make it somehow stand by itself. Initialy, I thought tieing it to the house may be easier … more