STM32F3硬件I2C与LSM303DLHC通信

I2C(Inter-Integrated Circuit)总线是一种 两线式串行总线,用于连接微控制器 及其外围设备。和SPI一样,也是一种常用的串行通信方式。
STM32微控制器提供硬件I2C,对它进行相应配置就可以用来进行多个设备之间的通信。
使用步骤:
1. Enable peripheral clock 
2. Enable SDA, SCL and SMBA (when used) GPIO clocks 
3. Peripherals alternate function: Call GPIO_Init() function.
4. Program the Mode, Timing , Own address, Ack and Acknowledged Address using the I2C_Init() function.
5. Enable the NVIC and the corresponding interrupt   if you need to use interrupt mode.
7. When using the DMA mode Configure the DMA 
8. Enable the I2C using the I2C_Cmd() function.
9. Enable the DMA when using DMA mode in the transfers.
基于STM32F3discovery开发板
MCU:STM32F303VC作为主机
从机”LSM303DL
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值