This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] RTOS/TM4C123GH6ZRB:在 BIOS 启动之前使用 I2C 访问 TCA9535

Guru**** 2470720 points
Other Parts Discussed in Thread: TCA9535

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/676784/rtos-tm4c123gh6zrb-tca9535-access-using-i2c-before-the-bios-start

器件型号:TM4C123GH6ZRB
主题中讨论的其他器件:TCA9535

工具/软件:TI-RTOS

您好!

在 BIOS 开始之前、我正在使用 I2C0主器件访问从器件 TCA9535。 这在调试模式下运行良好、但在释放模式下不运行。

使用的工作台:IAR Embedded Workbench IDE

下面是我的代码片段。

空 init()

SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB);

//使用前必须启用 I2C0外设。
SysCtlPeripheralEnable (SYSCTL_Periph_I2C0);

//为端口 B2和 B3上的 I2C0功能配置引脚复用。
GPIOPinConfigure (GPIO_PB2_I2C0SCL);
GPIOPinConfigure (GPIO_PB3_I2C0SDA);

GPIOPinTypeI2CSCL (GPIO_PORTB_BASE、GPIO_PIN_2);
GPIOPinTypeI2C (GPIO_PORTB_BASE、GPIO_PIN_3);

GPIOPadConfigSet (GPIO_PORTB_BASE、GPIO_PIN_3、GPIO_Strength _8mA_SC、GPIO_DIR_MODE_HW | GPIO_PIN_TYPE_OD);
//启用 I2C0主机模块
I2CMasterEnable (I2C0_BASE);

I2C_init();

void TCA9535_access (uint8_t *txData、uint8_t txdataLen、uint8_t *rxdata、uint8_t rxdataLen)

uint8_t ret = 0;
uint8_t txdataIndex = 0、rxdataIndex = 0;

I2CMasterSlaveAddrSet (I2C0_BASE、TCA9535_address、false);
while (I2CMasterBusy (I2C0_BASE)){}

if (txdataLen!= 0)

if (txdataLen = 1)

I2CMasterDataPut (I2C0_BASE、txData[txdataIndex]);
I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_SINGLE_SEND);
while (I2CMasterBusy (I2C0_BASE)){}

其他

I2CMasterDataPut (I2C0_BASE、txData[txdataIndex]);
I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_SEND_START);
while (I2CMasterBusy (I2C0_BASE)){}

for (txdataIndex = 1;txdataIndex <(txdataLen - 1);txdataIndex++)

I2CMasterDataPut (I2C0_BASE、txData[txdataIndex]);
I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_SEND_CONT);
while (I2CMasterBusy (I2C0_BASE)){}

I2CMasterDataPut (I2C0_BASE、txData[txdataIndex]);
I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_SEND_FINISH);
while (I2CMasterBusy (I2C0_BASE)){}


if (rxdataLen!= 0)

I2CMasterSlaveAddrSet (I2C0_BASE、TCA9535_address、TRUE);
while (I2CMasterBusy (I2C0_BASE)){}

if (rxdataLen = 1)

I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_SINGLE_Receive);
while (I2CMasterBusy (I2C0_BASE)){}

RET = I2CMasterDataGet (I2C0_BASE)& 0xFF;
rxdata[rxdataIndex]= ret;

其他

I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_Receive_start);
while (I2CMasterBusy (I2C0_BASE)){}

RET = I2CMasterDataGet (I2C0_BASE)& 0xFF;
rxdata[rxdataIndex]= ret;

for (rxdataIndex = 1;rxdataIndex <(rxdataLen - 1);rxdataIndex++)

I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_Receive_CONT);
while (I2CMasterBusy (I2C0_BASE)){}

RET = I2CMasterDataGet (I2C0_BASE)& 0xFF;
rxdata[rxdataIndex]= ret;

I2CMasterControl (I2C0_BASE、I2C_MASTER_CMD_BURST_Receive_finish);
while (I2CMasterBusy (I2C0_BASE)){}

RET = I2CMasterDataGet (I2C0_BASE)& 0xFF;
rxdata[rxdataIndex]= ret;


请提供您的信息。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    [引用用户="Gowtham R"]

    GPIOPadConfigSet (GPIO_PORTB_BASE、GPIO_PIN_3、GPIO_Strength _8mA_SC、GPIO_DIR_MODE_HW | GPIO_PIN_TYPE_OD);[/引用]

    我几乎肯定的是、这个函数证明对您之前使用 的"GPIOPinType()& GPIOPinConfigure()"-尤其是  在使用 I2C 时。

    移除"PadConfig"呼叫应该会快速而轻松-我怀疑将成功...

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    调试模式和释放模式之间是否有不同的优化?