/** @page I2C_DataExchange I2C1 Master and Slave data exchange
@verbatim
******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
* @file I2C/I2C_TwoBoards/I2C_DataExchange/readme.txt
* @author MCD Application Team
* @version V1.2.1
* @date 30-September-2014
* @brief Description of the Comparator in interrupt mode example
******************************************************************************
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
@endverbatim
@par Example description
This is a typical example of how to use the I2C software library to ensure the
steps of an I2C communication between slave and master.
This is a two phase example that requires two boards(Master an Slave)
- Phase 1:
In master board I2C peripheral is configured in Master Transmitter with Interrupt,
where in Slave board I2C peripheral is configured in Slave Receiver with Interrupt.
The master will send Data to Slave according to the defined buffer size.
- Phase 2:
In master board I2C peripheral is configured in Master Receiver with Polling,
where in Slave board I2C peripheral is configured in Slave Transmitter with
Interrupt.
Once the master has initiated the communication (Start condition), the slave
will send back the previously received data to the master
At the end of the data transfer, a data consistency check will be performed
in master side and in case of mismatch between sent and received data, LED4
will toggle infinitely. Otherwise LED1 will toggle.
Communication error are handled in Slave side, their occurrence will be signaled
by puting On LED2.
The "main.h" file allows different possibilities of configuration of this example:
- Addressing mode : 7-bit or 10-bit
- Safe procedure for master receiver
- I2C speed: Fast mode or Standard mode
- Buffer size also can be configured
and though by choosing the desired configuration within main.h file.
@par Directory contents
- I2C/I2C_TwoBoards/I2C_DataExchange/X/main.c Main file
- I2C/I2C_TwoBoards/I2C_DataExchange/X/main.h Header for Main file
- I2C/I2C_TwoBoards/I2C_DataExchange/X/stm8l10x_conf.h Library Configuration file
- I2C/I2C_TwoBoards/I2C_DataExchange/X/stm8l10x_it.c Interrupt routines source
- I2C/I2C_TwoBoards/I2C_DataExchange/X/stm8l10x_it.h Interrupt routines declaration
where X stands for Master or Slave directories.
@par Hardware and Software environment
- This example runs on STM8L10x devices.
- This example has been tested with STMicroelectronics STM8L101-EVAL evaluation
board and can be easily tailored to any other development board.
- STM8L1x-EVAL Set-up
- Connect I2C1 Master SCL pin (PC.01) to I2C1 Slave SCL (PC.01)
- Connect I2C1 Master SDA pin (PC.00) to I2C1 Slave SDA (PC.00)
- Connect the two-boards grounds together
- Other platform Set-up
- Connect I2C1 Master SCL pin (PC.01) to I2C1 Slave SCL (PC.01)
- Connect I2C1 Master SDA pin (PC.00) to I2C1 Slave SDA (PC.00)
- 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 the two-boards grounds together
@note The pull-up resitors are already implemented on the STM8L1x-EVAL evaluation boards.
@par How to use it ?
In order to make the program work, you must do the following :
- Copy all source files from this example folder to the template folder under
Project\STM8L10x_StdPeriph_Templates
- Open your preferred toolchain
- Rebuild all files and load your image into target memory
- Run the example
@note
- STM8L10x devices are STM8L microcontrollers with a Flash memory density up to 8 Kbytes.
* <h3><center>© COPYRIGHT STMicroelectronics</center></h3>
*/
没有合适的资源?快使用搜索试试~ 我知道了~
STM8L10x_StdPeriph_Lib.zip_stm8_stm8 example code_stm8l10X
共231个文件
h:91个
c:87个
txt:35个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 170 浏览量
2022-09-23
02:41:16
上传
评论
收藏 4.41MB ZIP 举报
温馨提示
stm8 代码编程例子,适用于刚刚学习stm8 单片机的初学者
资源推荐
资源详情
资源评论
收起资源包目录
STM8L10x_StdPeriph_Lib.zip_stm8_stm8 example code_stm8l10X (231个子文件)
stm8l10x_tim2.c 63KB
stm8l10x_tim3.c 63KB
stm8l10x_i2c.c 35KB
stm8l10x_flash.c 26KB
stm8l_eval_spi_sd.c 25KB
stm8l_eval_i2c_ee.c 23KB
stm8l10x_usart.c 19KB
stm8l10x_tim4.c 19KB
stm8l10x_comp.c 14KB
stm8l10x_exti.c 14KB
stm8l10x_spi.c 13KB
stm8l10x_gpio.c 13KB
stm8l10x_itc.c 11KB
stm8l10x_it.c 11KB
stm8l101_eval.c 10KB
stm8l_eval_lcd.c 10KB
stm8l10x_it.c 10KB
stm8l10x_it.c 10KB
stm8l10x_it.c 10KB
stm8l10x_it.c 10KB
stm8l10x_it.c 10KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
main.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
stm8l10x_it.c 9KB
main.c 8KB
main.c 8KB
main.c 8KB
stm8l10x_beep.c 8KB
main.c 7KB
main.c 7KB
stm8l10x_clk.c 6KB
stm8l10x_wfe.c 6KB
stm8l10x_awu.c 6KB
main.c 6KB
main.c 6KB
main.c 6KB
main.c 6KB
main.c 6KB
main.c 5KB
main.c 5KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
stm8l10x_iwdg.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
stm8l10x_irtim.c 4KB
stm8l10x_rst.c 4KB
main.c 4KB
main.c 4KB
main.c 4KB
main.c 3KB
main.c 3KB
stm8_interrupt_vector.c 3KB
main.c 3KB
main.c 3KB
main.c 3KB
stm8l10x_stdperiph_lib_um.chm 3.97MB
project.ewd 6KB
project.ewp 24KB
project.eww 161B
main.h 85KB
stm8l10x.h 54KB
stm8l10x_i2c.h 27KB
stm8l10x_tim3.h 27KB
stm8l10x_tim2.h 26KB
stm8l10x_usart.h 12KB
stm8l10x_spi.h 11KB
stm8l10x_tim4.h 10KB
stm8l_eval_spi_sd.h 10KB
共 231 条
- 1
- 2
- 3
资源评论
钱亚锋
- 粉丝: 88
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功