CC2640R2F 支持硬件I2C吗? 如果支持硬件I2C的最大传输速度是多少? 有相关的文档说明吗?
Viki Shi:
有硬件I2C,传输速率可自己配置,代码里有如下几种:
typedef enum {I2C_100kHz= 0,/*!< I2C Standard-mode. Up to 100 kbit/s. */I2C_400kHz= 1,/*!< I2C Fast-mode. Up to 400 kbit/s. */I2C_1000kHz= 2,/*!< I2C Fast-mode Plus. Up to 1Mbit/s. */I2C_3330kHz= 3,/*!< I2C High-speed mode. Up to 3.4Mbit/s. */I2C_3400kHz= 3,/*!< I2C High-speed mode. Up to 3.4Mbit/s. */ } I2C_BitRate;代码链接:http://dev.ti.com/tirex/explore/node?node=AHLmQux2wAaoYaHFItp0bw__krol.2c__LATEST
WK C:
回复 Viki Shi:
#define I2C0_SCL0 IOID_12 //i2c SCL #define I2C0_SDA0 IOID_13 //i2c SDA typedef enum CC2640R2_LAUNCHXL_I2CName { CC2640R2_LAUNCHXL_I2C0 = 0, CC2640R2_LAUNCHXL_I2CCOUNT } CC2640R2_LAUNCHXL_I2CName; I2CCC26XX_Object _i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2CCOUNT]; const I2CCC26XX_HWAttrsV1 _i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2CCOUNT] = { { .baseAddr = I2C0_BASE, .powerMngrId = PowerCC26XX_PERIPH_I2C0, .intNum = INT_I2C_IRQ, .intPriority = ~0, .swiPriority = 0, .sdaPin = I2C0_SDA0, .sclPin = I2C0_SCL0, } }; const I2C_Config cc26xxI2C_config[CC2640R2_LAUNCHXL_I2CCOUNT] = { { .fxnTablePtr = &I2CCC26XX_fxnTable, .object = &_i2cCC26xxObjects[CC2640R2_LAUNCHXL_I2C0], .hwAttrs = &_i2cCC26xxHWAttrs[CC2640R2_LAUNCHXL_I2C0] }, }; //I2C 句柄及参数 static I2C_Handle cc2640_I2C_Handle; static I2C_Params cc2640_I2C_Params; static I2C_Transaction transaction; //初始化I2C void i2c_init(void) { I2C_Params_init(&cc2640_I2C_Params); cc2640_I2C_Params.transferMode = I2C_MODE_BLOCKING; cc2640_I2C_Params.bitRate = I2C_3330kHz; cc2640_I2C_Params.transferCallbackFxn = NULL; cc26xxI2C_config[CC2640R2_LAUNCHXL_I2C0].fxnTablePtr->initFxn((I2C_Handle)&cc26xxI2C_config[CC2640R2_LAUNCHXL_I2C0]); cc2640_I2C_Handle = cc26xxI2C_config[CC2640R2_LAUNCHXL_I2C0].fxnTablePtr->openFxn((I2C_Handle)&cc26xxI2C_config[CC2640R2_LAUNCHXL_I2C0],&cc2640_I2C_Params); if (cc2640_I2C_Handle == NULL) { *((uint32 *)0x40082270) = 1; } } 我按上面的程序配置 SCL都是只有300多KHz左右, 上面的配置有问题吗? 还是CC2640R2F硬件I2C有最大频率限制?
Viki Shi:
回复 WK C:
手册上原文是这样:The I 2C interface is used to communicate with devices compatible with the I 2C standard. The I 2C interface is capable of 100-kHz and 400-kHz operation, and can serve as both I 2C master and I 2C slave.
因为实验室里我们只测试并验证了 100-kHz和 400-kHz ,但是有客户设置过其他值,1M以下应该都没有问题。
WK C:
回复 Viki Shi:
硬件I2C中的起始和结束时间是多少,
Viki Shi:
回复 WK C:
I2C起始和结束的时间请查看时序图
WK C:
回复 Viki Shi:
硬件I2C只是发送或接收数据而已, 起始和停止不处理?
Viki Shi:
回复 WK C:
时序在底层已处理,开放给用户的是直接调用的API接口
WK C:
回复 Viki Shi:
有没有时序图提供, 我是使用硬件I2C驱动OLED显示.
Viki Shi:
回复 WK C:
I2C时序图网上搜一下就有了