I2C_24C02

所属分类:单片机开发
开发工具:Objective-C
文件大小:49KB
下载次数:8
上传日期:2014-12-19 15:20:40
上 传 者mcujishu
说明:  STM32单片机控制iic芯片24C02读写,完整工程程序,可以直接使用,非常方便
(STM32 MCU control iic 24C02 chip reader, complete engineering program, can be used directly, very convenient)

文件列表:
I2C_24C02\MDK_prj\cortexm3_macro.lst (26019, 2009-12-21)
I2C_24C02\MDK_prj\I2C_24C02.Opt (3746, 2009-12-22)
I2C_24C02\MDK_prj\I2C_24C02.plg (170, 2009-12-21)
I2C_24C02\MDK_prj\I2C_24C02.Uv2 (3267, 2009-12-21)
I2C_24C02\MDK_prj\I2C_24C02_I2C_24C02.dep (6315, 2009-12-22)
I2C_24C02\MDK_prj\I2C_24C02_Opt.Bak (3747, 2009-12-21)
I2C_24C02\MDK_prj\I2C_24C02_Target 1.dep (76, 2009-12-21)
I2C_24C02\MDK_prj\I2C_24C02_Uv2.Bak (0, 2009-12-21)
I2C_24C02\MDK_prj\Output\cortexm3_macro.o (2396, 2009-12-21)
I2C_24C02\MDK_prj\Output\ExtDll.iex (19, 2009-12-21)
I2C_24C02\MDK_prj\Output\I2C_24C02.hex (17548, 2009-12-21)
I2C_24C02\MDK_prj\Output\I2C_24C02.htm (64674, 2009-12-21)
I2C_24C02\MDK_prj\Output\I2C_24C02.lnp (545, 2009-12-21)
I2C_24C02\MDK_prj\Output\I2C_24C02.plg (196, 2009-12-22)
I2C_24C02\MDK_prj\Output\I2C_24C02.sct (479, 2009-12-21)
I2C_24C02\MDK_prj\Output\I2C_24C02.tra (1791, 2009-12-21)
I2C_24C02\MDK_prj\Output\i2c_ee.d (643, 2009-12-21)
I2C_24C02\MDK_prj\Output\main.d (615, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_flash.d (373, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_gpio.d (427, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_i2c.d (418, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_it.d (685, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_lib.d (666, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_nvic.d (365, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_rcc.d (357, 2009-12-21)
I2C_24C02\MDK_prj\Output\stm32f10x_vector.o (5672, 2009-12-21)
I2C_24C02\MDK_prj\Src\i2c_ee.c (14039, 2009-12-21)
I2C_24C02\MDK_prj\Src\i2c_ee.h (2236, 2009-12-21)
I2C_24C02\MDK_prj\Src\main.c (11014, 2009-12-21)
I2C_24C02\MDK_prj\Src\platform_config.h (2154, 2009-12-21)
I2C_24C02\MDK_prj\Src\stm32f10x_conf.h (6492, 2009-12-21)
I2C_24C02\MDK_prj\Src\stm32f10x_it.c (29218, 2008-09-21)
I2C_24C02\MDK_prj\Src\stm32f10x_it.h (3842, 2008-09-21)
I2C_24C02\MDK_prj\Src\stm32f10x_vector.s (12871, 2008-09-21)
I2C_24C02\MDK_prj\stm32f10x_vector.lst (38289, 2009-12-21)
I2C_24C02\MDK_prj\Output (0, 2014-12-19)
I2C_24C02\MDK_prj\Src (0, 2014-12-19)
I2C_24C02\MDK_prj (0, 2014-12-19)
I2C_24C02 (0, 2014-12-19)
... ...

/******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** * File Name : readme.txt * Author : MCD Application Team * Version : V2.0.3 * Date : 09/22/2008 * Description : Description of the I2C and M24C08 EEPROM communication 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. *******************************************************************************/ Example description =================== This example provides a basic example of how to use the I2C software library and an associate I2C EEPROM driver to communicate with an M24C08 EEPROM. I2C1 is configured in Master transmitter during write operation and in Master receiver during read operation from I2C EEPROM. The speed is set to the maximum frequency of 400kHz. This value is defined in the I2c_ee.c file, which could be in the range of 0 to 400KHZ. One I2C EEPROM Block address where the program will write the buffer have to be selected from the four address available and defined in the I2c_ee.h file. The EEPROM address where the program start the write and the read operations is defined in the main.c file. First, the contents of Tx1_Buffer are written to the EEPROM_WriteAddress1 and the written data are read. The written and the read buffers data are then compared. 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, Tx2_Buffer 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. 本例展示了如何利用I2C软件库和关联的I2C EEPROM驱动来实现与24C02 EEPROM的数据交换。 在对EEPROM进行写操作的时候,将I2C1设置为主发送端(Master transmitter),而在读操作的时候, 则设置为主接收端(Master receiver)。在文件I2c_ee.c中,将EEPROM的地址定义为0xA0。 传输时钟默认为400KHz,也可以在文件I2c_ee.c重新定义。在I2c_ee.c需把I2C_Pagesize由16改为4。 对于STM3210B_LK1板,由于板上EEPROM的片选管脚都接地,因此在文件I2c_ee.h中只能选择定义EEPROM_Block0_ADDRESS为0xA0。 运行程序,首先,第一次读写把Tx1_Buffer中的数据写入EEPROM_WriteAddress1, 再把数据从中读出存入Rx1_Buffer,比较Tx1_Buffer和Rx1_Buffer来检验读写是否正确。 然后把EEPROM设为待命状态(Standby State)。再进行第二次读写把Tx2_Buffer中的数据写入EEPROM_WriteAddress2, 再把数据从中读出存入Rx2_Buffer,比较Tx2_Buffer和Rx2_Buffer来检验第二次读写是否正确。 最后,把2次写入的数据一起读出,存入Rx_Buffer中。 Directory contents ================== stm32f10x_conf.h Library Configuration file stm32f10x_it.c Interrupt handlers stm32f10x_it.h Interrupt handlers header file main.c Main program i2c_ee.c I2C EEPROM driver i2c_ee.h Header for the i2c_ee.c file Hardware environment ==================== This example runs on STMicroelectronics STM3210B-EVAL and STM3210E-EVAL evaluation boards with addition of the following hardware connection: - Connect I2C1 SCL pin (PB.06) to I2C EEPROM SCL (pin6) - Connect I2C1 SDA pin (PB.07) 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 Note: The pull-up resitors are already implemented on the STM3210B-EVAL and STM3210E-EVAL evaluation boards. 本例程可以运行在 STM3210B-LK1 , STM3210B-EVAL 和 STM3210E-EVAL 开发板上,并可以轻松移植到其他开发板。 - 连接 I2C1 SCL pin (PB.06) to I2C EEPROM SCL (pin6) - 连接 I2C1 SDA pin (PB.07) to I2C EEPROM SDA (pin5) - 检查有一个上拉电阻连接在 I2C SDA 管脚上 - 检查有一个上拉电阻连接在 I2C SCL 管脚上 - 连接 I2C EEPROM Vcc (pin8) to Vdd - 连接 I2C EEPROM Vss (pin4) to Vss - 连接 PC.04 - PC.07 到4个指示灯 LD1 - LD4 在STM3210B-LK1开发板上如果比较写入和接收的数据一致,则4个指示灯闪亮;反之,4个指示灯流水灯亮。 How to use it ============= In order to make the program work, you must do the following : - Create a project and setup all your toolchain's start-up files - Compile the directory content files and required Library files : + stm32f10x_lib.c + stm32f10x_i2c.c + stm32f10x_rcc.c + stm32f10x_nvic.c + stm32f10x_gpio.c + stm32f10x_flash.c - Link all compiled files and load your image into target memory - Run the example ******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE******

近期下载者

相关文件


收藏者