AnsweredAssumed Answered

STM32L4 HAL I2C communication

Question asked by danimihalca on Jan 9, 2016
Latest reply on Feb 10, 2016 by Amel N
Hello.

I recently started testing the communication over I2C on a NUCLEO-L476RG board using the HAL API.
Looking through the reference manual (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00083560.pdf ) and through the examples provided withSTM32Cube_FW_L4_V1.1.0, you need to set a 32 bit timing register before initialization (this also applies for usage with the LL).
Later on, I found that there exists a "tool" which helps you generate register's value http://www.st.com/web/en/catalog/tools/PF258335 , but this is specified to be related for the  STM32F3xx and STM32F0xx series ( which have a maximum I2C clock frequency at 72MHz, while L4 works up to 80MHz).
To see a proper usage of the API, I looked at the I2C_TwoBoards_ComIT project and observer that the timing register value used was 0x00D00E28 (which should work at 1Mhz with Rise time = 120ns, Fall time = 25ns and use the I2C source clock frequency from the Sysclock set at 80MHz, as mentioned in the comments). Nevertheless, I have managed to run that example and successfully communicated with a secondary (slave) board.

I have several questions reqarding I2C:

1) Can I assume that the above provided timing register value is valid and outputs at the specified frequency with those rise/fall times?

2) Can I use that timing tool (Excel file) which is destined for STM32F3xx and STM32F0xx to calculate register values for my STM32L476RG? Will I obtain valid ones (the document is password protected)? 

3) Is there anywhere a tool to calculate the value for L4 which lets me set input clock frequency up to 80Mhz ?

4) The example I2C_TwoBoards_ComIT suggests that the board will communicate over I2C at 1Mhz frequency.  In the reference manual, it is specified that if you want to achieve 1Mhz, fast mode plus must be enabled (HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus) I have found the function in stm32l4xx_hal_i2c_ex.h). Why is that example working even though that function is nowhere called in the code?

5) I want to read/write over I2C from an AT24C256 EEPROM memory (http://www.atmel.com/Images/doc0670.pdf ). In order to make it work, I had used the above mentioned timing value and power the memory at 3.3V. Sometimes (2-3), I read different values than the ones which should be returned.
a) Why does the communication work at 3.3V and doesn't at 5V ( even though in the EEPROM's datasheet at Table 4, the clock frequency can be at most 1000KHz at 5V and this should mean that for 3.3V, it should be somewhere between 400-1000KHz) ?  The EEPROM memory works with an Arduino UNO, regardless of the powering mode (3.3V or 5V - in its sources, it is specified that the output frequency is at 100KHz). 
b) Can you suggest me a timing value (or output clock freq and rise/fall time) so that no data loss should happen when using the EEPROM memory , regardless of the powering mode of the EEPROM memory (the datasheet provides minimum or maximum values only for 1.8V, 2.5V and 5V) ?

Thank you!

Outcomes