I2C
所属分类:单片机开发
开发工具:C/C++
文件大小:45KB
下载次数:114
上传日期:2012-05-07 13:08:07
上 传 者:
水瓶座
说明: stm8 I2c源代码
www.zxkjmcu.com
文件列表:
I2C (0, 2009-03-10)
I2C\I2C_10bitsCommunication (0, 2009-03-10)
I2C\I2C_10bitsCommunication\main_master_10bit.c (5166, 2008-09-25)
I2C\I2C_10bitsCommunication\main_slave_10bit.c (5084, 2008-09-25)
I2C\I2C_10bitsCommunication\stm8_interrupt_vector.c (3403, 2008-09-25)
I2C\I2C_10bitsCommunication\stm8s_conf.h (5626, 2008-09-25)
I2C\I2C_10bitsCommunication\stm8s_it.c (14105, 2008-09-25)
I2C\I2C_10bitsCommunication\stm8s_it.h (3671, 2008-09-25)
I2C\I2C_EEPROMRandomRead (0, 2009-03-10)
I2C\I2C_EEPROMRandomRead\main.c (5716, 2008-09-25)
I2C\I2C_EEPROMRandomRead\stm8_interrupt_vector.c (3401, 2008-09-25)
I2C\I2C_EEPROMRandomRead\stm8s_conf.h (5622, 2008-09-25)
I2C\I2C_EEPROMRandomRead\stm8s_it.c (14099, 2008-09-25)
I2C\I2C_EEPROMRandomRead\stm8s_it.h (3668, 2008-09-25)
I2C\I2C_EEPROMReadWrite (0, 2009-03-10)
I2C\I2C_EEPROMReadWrite\main.c (7449, 2008-09-25)
I2C\I2C_EEPROMReadWrite\stm8_interrupt_vector.c (3401, 2008-09-25)
I2C\I2C_EEPROMReadWrite\stm8s_conf.h (5728, 2008-09-25)
I2C\I2C_EEPROMReadWrite\stm8s_it.c (14097, 2008-09-25)
I2C\I2C_EEPROMReadWrite\stm8s_it.h (3667, 2008-09-25)
I2C\I2C_EEPROMSequentialRead (0, 2009-03-10)
I2C\I2C_EEPROMSequentialRead\main.c (5115, 2008-09-25)
I2C\I2C_EEPROMSequentialRead\stm8_interrupt_vector.c (3401, 2008-09-25)
I2C\I2C_EEPROMSequentialRead\stm8s_conf.h (5628, 2008-09-25)
I2C\I2C_EEPROMSequentialRead\stm8s_it.c (14300, 2008-09-25)
I2C\I2C_EEPROMSequentialRead\stm8s_it.h (3672, 2008-09-25)
I2C\I2C_Interrupt (0, 2009-03-10)
I2C\I2C_Interrupt\main.c (4181, 2008-09-25)
I2C\I2C_Interrupt\stm8_interrupt_vector.c (3401, 2008-09-25)
I2C\I2C_Interrupt\stm8s_conf.h (5618, 2008-09-25)
I2C\I2C_Interrupt\stm8s_it.c (15142, 2008-09-25)
I2C\I2C_Interrupt\stm8s_it.h (3661, 2008-09-25)
/** @page I2C_Interrupt I2C data transfer in interrupt mode
@par Example description
This example provides a short description of how to:
- Transfer a data byte to a second I2C using interrupts.
- In this example the code is written for a master I2C as we generate a START.
- To perform the example in slave mode, just remove the START command line in the code.
- The communication is configured in 7bit addressing mode with a clock speed set to 100KHz.
- The event and buffer interrupts are enabled for the I2C.
- Once the start signal is generated the interrupt function detects each interrupt and sequentially sends data till the STOP.
- In case of Slave I2C, the start is not generated.
This example runs on STM8S-128K and STM8S-32K products
@par Directory contents
- main.c Main file containing the "main" function
- stm8s_conf.h Library Configuration file
- stm8s_it.c Interrupt routines source
- stm8s_it.h Interrupt routines declaration
- stm8_interrupt_vector.c Interrupt vectors table
@par Hardware environment
2 solutions:
- Connect the STM8S I2C to a second I2C
- SDA pin -> SDA pin.
- SCL pin -> SCL pin.
- On SDA & SCL pins do not forget pull-up resistors (4.7k ohms).
- Do not forget to power up the EEPROM (VDD =5V).
- Set the second I2C board with address 0xA0, frequency 100KHz.
- Connect the STM8S I2C to an Aardvark I2C/SPI module
- SDA pin -> SDA pin.
- SCL pin -> SCL pin.
- On SDA & SCL pins do not forget pull-up resistors (4.7k ohms).
- Pull-up is integrated by default in the Aardvark module.
- Set the Aardvark module as slave. In the graphical interface set address 0x50(=0xA0) in 100KHz.
- Use same setting (add & frequency) if you use Aardvark in master mode (and your I2C device in slave mode).
@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
- Compile the directory content files and required Library files :
+ stm8s_i2c.c
+ stm8s_gpio.c
- Rebuild all files: Project->Rebuild all.
- Load project image: Debug->Start/Stop Debug Session
- In case where Aardvark is slave enable it as slave.
- In case where Aardvark is master, run the program first then send the data with Aardvark interface.
- Run program: Debug->Run (F5).
- The buffer will be filled up with number of data you decided to capture.
- The four LEDs will blink at the end of I2C communication sequence.
Go to main file: I2C_Interrupt\main.c
*/
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
近期下载者:
相关文件:
收藏者: