主题中讨论的其他器件:TM4C123、
工具/软件:TI-RTOS
大家好、我已经为 BNO055 IMU 布线了一个驱动器、以便与我的 tm4c123配合使用。
当我单步执行程序时、驱动程序按预期工作、所有数据均可正确读取并按预期工作。 此外、该器件还可在连续模式下以100Hz 读取速率与 Arduino 配合使用
但是、当我尝试以100Hz 的读取速率在任务内持续运行它时、我发现总线故障和 SDA 被从器件拉低、或者我由于某种原因处于空闲任务、因此不会离开。
因此、当时钟扩展到远离从器件或任务可能发生变化时、我认为 I2C API 会发生故障。
此外、是否有从总线故障中恢复的软件方法? 例如、i2c API 是否需要处理该问题?
这是 i2c 的读取和写入
我将 TI-RTOS 用于 TM4c123GH6PM、这些函数从 void i2c_task_fxn ()中调用;它们在步进时按预期工作。
此外、我只想说我只打开 I2C_open (1、&i2cParams)一次、我是否应该为每次传输重新初始化这个?
//函数将 BNO055库连接到 TM4C 外设驱动程序// 读取函 数 s8 i2c_bno055_read (u8 dev_address、u8 reg_address、u8*reg_data、u8 cnt) { uint8_t txBuffer[10]; txBuffer[0]= reg_address; i2cTransaction.writeBuf = txBuffer; i2cTransaction.writeCount = 1; i2cTransaction.readBuf = reg_data; i2cTransaction.ReadCount = cnt; while (!I2C_transfer (i2c、&i2cTransaction)) { Task_sleep (10); } 返回0; } //函数将 BNO055库连接到 TM4C 外设驱动程序 //写入函 数 s8 i2c_bno055_write (u8 dev_address、u8 reg_address、u8 reg_data、u8 uintt 、u8 uintt) txBuffer[10]; txBuffer[0]= reg_address; 对于(k = 1;k < cnt+1;k++) { txBuffer[k]=*(reg_data+k-1); } i2cTransaction.slaveAddress = DEV_address; i2cTransaction.writeBuf = txBuffer; i2cTransaction.writeCount = cnt+1; i2cTransaction.readBuf = reg_data; i2cTransaction.ReadCount = 0; if (I2C_transfer (i2c、&i2cTransaction)) { 返回0; } LOG_info0 ("fault"); RESET_FAULT(); return 1; }
侧注:在初始设置期间,我经常使用 Task_sleep()来处理读取和写入之间的延迟,这是否可能是一个问题?
在 SDA 被拉至低电平后、我在这里结束
void ide_run() { int i; if (BIOS_smpEnabled = true){ UINT CoreID = Core_getid(); 对于(i = 0;i < Idle_funclist.length;i++){ if (idle_coreList.elem[i]=CoreID){ idle_funclist.elem[i](); } } 否则{ 对于(i = 0;i < Idle_funclist.length;i++){ idle_funclist.elem[i](); } }
请提供任何帮助。