Hello. I'm trying to run a simple I2C test with my STM32 board and I can't get it to work. I'm using STM32F0 Discovery kit (master) and one slave device (some module) that I want to communicate with via I2C bus. Devices are connected via lines SCL, SDA, GND, Vdd and Reset (active low; raised by master). This is my first time using I2C bus on STM32 kit.
In datasheet of my module it
says that after the module is either powered on or reset, the module
controller will always send a special 4 byte long msg (kind of “Hello” packet) to the host system (implying it is ready to
work). So for a quick test of I2C communication I just wanted my
master (STM32) to read this »Hello« packet via I2C to see if it's working.
So my general idea (code) was to:
1.) initialize HW (I2C, GPIO, LEDs...). Using internal pull-up resistors in I2C init
2.) write I2C "read" function for reading "Hello" packet sent from slave device
3.) print out "Hello" packet to see if it is correct one
In my "Reading" part of my code I first force restart of the slave device by forcing "reset" pin low. Then I try to read the "Hello" package sent by slave:
The problem is that the program gets stuck at the point of checking RXNE flag as the flag seems to never get set (always stays reset) and therefore no reading data occurs.
So my questions are:
1.) Should I use external pull-up resistors? Currently I'm only using internal ones, as I read (on some blog) that it should be good enough for simple I2C communication
2.) Is my concept of reading data (sent from I2C slave) correct?