/** @page I2C_EEPROM I2C1 in communication with I2C EEPROM.
@verbatim
******************** (C)COPYRIGHT 2010 STMicroelectronics *******************
* @file I2C/I2C_EEPROM/readme.txt
* @author MCD Application Team
* @version V1.4.0
* @date 09/24/2010
* @brief Description of the I2C EEPROM Example.
******************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
******************************************************************************
@endverbatim
@par Example description
This example provides a basic example of how to use the I2C software library
and an associated I2C EEPROM driver to communicate with an I2C EEPROM device
(here the example is interfacing with E24C64 EEPROMs .
At startup a message is displayed on the HyperTerminal (through USART asking
user to enter the data to write into the SPI FLASH. Each byte received is sent
back to the HyperTerminal and stored in the predefined buffer RxBuffer1.
The communication is managed by USART Transmit and Receive interrupts.
If user presses keyboard ENTER key or RxBuffer1 length is reached (defined by
RX_BUFFER1_SIZE in main.c , the program starts programming the I2C EEPROM with
data entered by the user.
Next, the content of RxBuffer1 is written to the EEPROM_WriteAddress1 and the
written data is read. The written and the read buffers data are then compared
and the result of this comparison is stored in the "TransferStatus1" variable.
Following the read operation, the program wait that the EEPROM reverts to its
Standby state.
A second write operation is, then, performed and this time, TxBuffer2 is
written to EEPROM_WriteAddress2, which represents the address just after the
last written one in the first write.
After completion of the second write operation, the written data are read.
The contents of the written and the read buffers are compared and the result
of this comparison is stored in the "TransferStatus2" variable.
I2C peripheral is configured in Master transmitter during write operation and
in Master receiver during read operation from I2C EEPROM. The speed is set to
200kHz.
For E24C64 device all the memory is accessible through the two-bytes
addressing mode and need to define block addresses. In this case, only the
physical address has to be defined (according to the address pins (E0,E1 and
E2 connection .
This address is defined in stm8_eval_i2c_ee.h (default is 0xA0: E0, E1 and E2
tied to ground .
The EEPROM addresses where the program start the write and the read operations
is defined in the main.c file.
@par Directory contents
- I2C/I2C_EEPROM/main.c Main file
- I2C/I2C_EEPROM/stm8l15x_conf.h Library Configuration file
- I2C/I2C_EEPROM/stm8l15x_it.c Interrupt routines source
- I2C/I2C_EEPROM/stm8l15x_it.h Interrupt routines declaration
@par Hardware and Software environment
- This example runs on STM8L15x High-Density, Medium-Density Plus and
Medium-Density Devices.
- This example has been tested with STMicroelectronics STM8L1528-EVAL
(STM8L15x High-Density devices) and STM8L1526-EVAL (STM8L15x Medium-Density)
devices evaluation boards and can be easily tailored to any other
development board.
- STM8L1528-EVAL Set-up
- Make sure that the LCD glass daughter board is mounted in IO position.
For more details please refer to the evaluation board user manual.
- For write operations, make sure the jumper JP6 "E2P_WP" is connected on
the board (If this jumper is not connected, the EEPROM will be write-
protected .
- Connect a null-modem female/female RS232 cable between the DB9 connector
CN1 and PC serial port.
- Make sure that JP5 jumper is in RS232 position
- Make sure that JP11 jumper is in RS232 position
- Make sure that JP12 jumper is in RS232 position
- STM8L1526-EVAL Set-up
- Make sure that the LCD glass daughter board is mounted in IO position.
For more details please refer to the evaluation board user manual.
- Make sure that Jumper JP7 is set in poistion 1-2 (I2C position .
- For write operations, make sure the jumper JP14 "E2P_WP" is connected on
the board (If this jumper is not connected, the EEPROM will be write-
protected .
- Connect a null-modem female/female RS232 cable between the DB9 connector
CN1 and PC serial port.
- Make sure that JP5 jumper is in RS232 position
- Make sure that the LCD glass daughter board is mounted in IO position.
- Other platform Set-up
- Use STM8L1526-EVAL hardware configuration defines.
- Connect I2C1 SCL pin (PC.01 to I2C EEPROM SCL (pin6
- Connect I2C1 SDA pin (PC.00 to I2C EEPROM SDA (pin5
- Check that a pull-up resistor (4.7K is connected on one I2C SDA pin
- Check that a pull-up resistor (4.7K is connected on one I2C SCL pin
- Connect I2C EEPROM Vcc (pin8 to Vdd
- Connect I2C EEPROM Vss (pin4 to Vss
- For E24C64: Connect I2C EEPROM E0, E1 and E2 (pin1, pin2 and pin3 to Vss
@note The pull-up resitors are already implemented on the STM8L1528-EVAL and
STM8L1526-EVAL evaluation boards.
- HyperTerminal configuration:
- Word Length = 7 Bits
- One Stop Bit
- Odd parity
- BaudRate = 115200 baud
@par How to use it ?
In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- Add the required Library files :
- stm8l15x_clk.c
- stm8l15x_dma.c
- stm8l15x_exti.c
- stm8l15x_gpio.c
- stm8l15x_i2c.c
- stm8l15x_spi.c
- stm8l15x_syscfg.c
- stm8l15x_usart.c
- stm8_eval.c (under Utilities/STM8_EVAL)
- stm8_eval_i2c_ee.c (under Utilities/STM8_EVAL/Common)
- Edit stm8l15x.h file to select the device you are working on.
- Edit stm8_eval.h file to select the evaluation board you will use.
@note Limitation : Used with Cosmic compiler, this example may not work properly
with STM8L15x High density devices.
@b Tip: You can tailor the provided project template to run this example, for
more details please refer to "stm8l15x_stdperiph_lib_um.chm" user
manual; select "Peripheral Examples" then follow the instructions
provided in "How to proceed" section.
- Link all compiled files and load your image into target memory
- Run the example
@note
- Medium-Density devices are STM8L15x microcontrollers where the
Flash memory density ranges between 16 and 32 Kbytes.
- Medium density Plus devices are STM8L151R6, STM8L152R6 microcontrollers
where the Flash memory density is fixed and equal to 32 Kbytes and with
wider range of peripheral and features than the medium density devices.
- High-Density devices are STM8L15x microcontrollers where the
Flash memory density is 64 Kbytes and with the same peripheral set than
Medium Density Plus devices.
*/
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
- 1
- 2
- 3
- 4
- 5
前往页