Thread 中讨论的其他器件:C2000WARE
工具与软件:
我已经有一个在 I2C 之上使用 FIFO 的 EEPROM、想在 I2C 之上添加一个 SHT3X、如果要读取6个数据、需要关闭 FIFO、我不知道如何更改它、而且它不会影响 EEPROM 的读取和写入?
我为 SHT3X 单独准备了一些读写函数(复制的 EEPROM)、试图仅关闭 FIFO 读取、但失败了、我不知道 why.please 会帮我。谢谢。
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.
工具与软件:
我已经有一个在 I2C 之上使用 FIFO 的 EEPROM、想在 I2C 之上添加一个 SHT3X、如果要读取6个数据、需要关闭 FIFO、我不知道如何更改它、而且它不会影响 EEPROM 的读取和写入?
我为 SHT3X 单独准备了一些读写函数(复制的 EEPROM)、试图仅关闭 FIFO 读取、但失败了、我不知道 why.please 会帮我。谢谢。
尊敬的荣荣荣荣:
确保您要 在模块处于复位状态时更改 I2C 设置、以防止产生任何不必要的结果。 例如 、这可以在 ISR 期间发生。
我为我的 SHT3X 单独准备了一些读写函数(复制的 EEPROM)、尝试仅关闭 FIFO 读取、但失败
您能否提供有关此方面的更多详细信息?
此致、
Aishwarya.
您好、Aishwarya、
我通常在进入函数后立即处理数据和状态判断,并最终执行状态判断,而我读取的函数可以引用我修改的官方程序
此致
__interrupt void
i2c_int1a_isr(void)
{
Uint16 IntSource, i;
//
// Read interrupt source
//
IntSource = I2caRegs.I2CISRC.all;
IntSource1 = I2caRegs.I2CSTR.bit.RRDY;
//
// Interrupt source = stop condition detected
//
if(IntSource == I2C_SCD_ISRC)
{
//
// If completed message was writing data, reset msg to inactive state
//
if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
{
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
}
else
{
//
// If a message receives a NACK during the address setup portion
// of the EEPROM read, the code further below included in the
// register access ready interrupt source code will generate a stop
// condition. After the stop condition is received (here), set the
// message status to try again. User may want to limit the number
// of retries before generating an error.
//
if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
{
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
}
//
// If completed message was reading EEPROM data, reset msg to
// inactive state and read data from FIFO.
//
else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
{
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
for(i=0; i < I2C_NUMBYTES; i++)
{
CurrentMsgPtr->MsgBuffer[i] = I2caRegs.I2CDRR;
}
{
//
// Check received data
//
for(i=0; i < I2C_NUMBYTES; i++)
{
if(I2cMsgIn1.MsgBuffer[i] == I2cMsgOut1.MsgBuffer[i])
{
PassCount++;
}
else
{
FailCount++;
}
}
if(PassCount == I2C_NUMBYTES)
{
pass();
}
else
{
fail();
}
}
}
}
}
else if (IntSource1 == 1)
{
// if (I2cMsg.status == I2C_MSG_STATUS_READ_BUSY)
// {
static Uint16 ReadCount;
ReadCount++;
Buffer[ReadCount] = I2caRegs.I2CDRR;
if(ReadCount == 5)
{
ReadCount=0;
}
// }
}
//
// Interrupt source = Register Access Ready
// This interrupt is used to determine when the EEPROM address setup
// portion of the read data communication is complete. Since no stop bit is
// commanded, this flag tells us when the message has been sent instead of
// the SCD flag. If a NACK is received, clear the NACK bit and command a
// stop. Otherwise, move on to the read data portion of the communication.
//
else if(IntSource == I2C_ARDY_ISRC)
{
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CMDR.bit.STP = 1;
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
}
else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
{
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
}
else if (I2cMsg.status == I2C_MSG_STATUS_WRITE_BUSY)
{
I2cMsg.status = I2C_MSG_STATUS_RW_OK;
// InitSetSHT3XI2ca();
I2caRegs.I2CFFRX.all =0x0040; // Enable RXFIFO, clear RXFFINT,
}
//I2caRegs.I2CMDR.all = 0x0000; // reset I2C
//I2caRegs.I2CMDR.all = 0x0020;
}
else
{
//
// Generate some error due to invalid interrupt source
//
__asm(" ESTOP0");
}
//
// Enable future I2C (PIE Group 8) interrupts
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}但在修改调试后、我发现无法触发数据来读取数据、接收寄存器中的数据保持一致、有时会出现触发条件、有时不会触发、但都不会被读取
我已经尝试使用 I2CIRC 寄存器的4个中断条件和 I2CSTR 的 RRDY 条件、但接收寄存器中的值不能被成功读取。
我应该如何改变它,我应该在哪种状态下读取它?
此致、
荣荣荣
如果我理解正确、那么 预期的数据在接收寄存器中、但是您无法在 ISR 中读取这些值来采取适当的操作? 请查看 C2000Ware EEPROM 示例以及此 E2E。 (+) TMS320F28035:通过 I2C 使用 EEPROM 进行读写操作- C2000微控制器论坛- C2000 ︎ 微控制器- TI E2E 支持论坛
但在我修改调试
什么是调试?
我能否关闭接收 FIFO 并继续打开发送 FIFO?
接收和发送 FIFO 相互独立、但协同工作。 根据需要、您可以关闭 FIFO、只需确保清除中断状态即可确保 FIFO 按预期运行。
此致、
Aishwarya.