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.

[参考译文] CCS:28035 I2C 始终在下一个确认周期生成 NACK 位

Guru**** 2540720 points


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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/624651/ccs-28035-i2c-always-generate-nack-bit-on-next-acknowledge-cycle

工具/软件:Code Composer Studio

我正在尝试在28035上处理不受支持的 PMBus 命令(通过生成 NACK 位)。

但不管我尝试了什么、NACK 始终会影响下一个命令周期。

在 I2CDRR 被读取前后、我已经尝试生成 NACK 位。 他们都不起作用。

是否有在同一周期生成 NACK 位的想法?

#include "DSP28x_Project.h"

void I2CA_Init (void);
__interrupt void i2c_int1a_ISR (void);
void I2CDataHandler ();

#define I2C_SLAVE_ADDR 0x58

结构 I2cISRInfo{
Int noCount;
Int arbCount;
int nackCount;
Int ardyCount;
Int rxCount;
int txCount;
int scdCount;
int assCount;
};

unsigned int data = 0;

unsigned char commandArray[256];
unsigned int cmdArrayIndex = 0;
unsigned char inDataStack[256];
unsigned int inDataIndex = 0;

struct I2cISRInfo;

void main (void)
{
uint16 i;

InitSysCtrl();
InitI2CGpio();
Dint;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.I2CINT1A =&i2c_int1a_ISR;
EDIS;
I2CA_Init();
对于(I = 0;I < 64;I++)
commandArray[i]= inDataStack[i]= 0;
info.arbCount = info.ardyCount = info.assCount = info.nackCount = info.noCount = info.rxCount = info.scdCount = info.txCount = 0;
PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
IER |= M_INT8;
EINT;

//应用程序循环
for (;;)
{
}
}

void I2CA_Init(void)
{
//初始化 I2C
I2caRegs.I2COAR = I2C_SLAVE_ADDR;//从地址- EEPROM 控制代码

I2caRegs.I2CPSC.all = 6;//预分频器-模块时钟需要7-12MHz
I2caRegs.I2CCLKL = 10;//注意:必须为非零
I2caRegs.I2CCLKH = 5;//注意:必须为非零
I2caRegs.I2CIER.ALL = 0x7f;//启用 SCD 和 ARDY 中断
I2caRegs.I2CMDR.ALL = 0x0020;//使 I2C 退出复位
//挂起时停止 I2C

return;
}

unsigned char nack = 0;

#pragma CODE_SECTION (i2c_int1a_isr、"ramfuncs")
_interrupt void i2c_int1a_isr (void) 
{ uint16 intSrc = I2caRegs.I2CISRC.bit.INTCODE; commandArray[cmdArrayIndex++]= intSrc; 开关(intSrc){ 情况 I2C_NO_ISRC: info.noCount++; 中断; 案例 I2C_ARB_ISRC: info.arbCount++; 中断; I2C_Nack_ISRC 案例: info.nackCount++; 中断; I2C_ARDY_ISRC 案例: info.ardyCount++; if (I2caRegs.I2CSTR.bit.nack = 1){ I2caRegs.I2CMDR.bit.STP= 1; I2caRegs.I2CSTR.All = I2C_CLR_Nack_bit; } 中断; I2C_RX_ISRC 案例: info.rxCount++; /* *假设每接收到其他 i2c 命令就会生成 NACK 位 但 NACK 位始终会影响下一个周期 * I2caRegs.I2CSTR.bit.RSFULL=1; if (inDataIndex & 1){ I2caRegs.I2CMDR.bit.NACKMOD = 1; I2caRegs.I2CMDR.bit.IRS = 0; I2caRegs.I2CMDR.bit.IRS = 1; NACK = 1; } 其他 NACK = 0; inDataStack[inDataIndex++]= I2caRegs.I2CDRR; I2caRegs.I2CSTR.bit.RSFULL=0; 中断; I2C_TX_ISRC 案例: info.txCount++; ++数据; I2caRegs.I2CDXR =数据; 中断; I2C_SCD_ISRC 案例: info.scdCount++; I2caRegs.I2CMDR.bit.IRS = 0; I2caRegs.I2CMDR.bit.IRS = 1; 中断; 案例 I2C_AAS_ISRC: info.assCount++; 中断; } PieCtrlRegs.PIEACX.ALL = PIEACK_group8; }

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

    您好、Archer、

    您是否查看过下表?

    您是否在从接收器模式下运行? 您可以尝试交换以下两条命令的顺序以遵循上述内容:

    I2caRegs.I2CMDR.bit.NACKMOD = 1;

    I2caRegs.I2CMDR.bit.IRS = 0;
    我猜您在下一个命令周期中会收到 NACK、因为 NACKMOD 将在第一个字节的最后一个数据位之后进行设置(请参阅下面的指南中的注释)。
    "重要:要在下一个确认周期发送 NACK 位、必须在最后一个数据位的上升沿之前设置 NACKMOD。"
    希望这对您有所帮助、
    Kevin