In JN-AN-1229 ,I want to use I2c communication

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

In JN-AN-1229 ,I want to use I2c communication

845 次查看
377086561
Contributor II

Hi Mario.

I saw a case of JN-AN-1221 and then borrowed from the application.

bool i2c_BusWriteReg(uint8 u8Address, uint8 u8Command, uint8 u8Length, uint8* pu8Data)
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(bTraceI2c, "i2c_BusWriteReg: Enter\n");
#endif

// First write I2C address + WRITE BIT on I2C bus
vAHI_SiMasterWriteSlaveAddr(u8Address, /* bReadStatus */ FALSE);
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_START_BIT,
/* bSetSTO */ E_AHI_SI_NO_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 1\n");
#endif
return FALSE;
}
while(bAHI_SiMasterPollTransferInProgress());

// Now write Command to I2C device
vAHI_SiMasterWriteData8(u8Command);

// Now write Data to I2C device
while (u8Length)
{
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_NO_START_BIT,
/* bSetSTO */ E_AHI_SI_NO_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 2\n");
#endif
return FALSE;
}
while(bAHI_SiMasterPollTransferInProgress());

===============================================》   #1

vAHI_SiMasterWriteData8(*pu8Data);
u8Length -= 1;
pu8Data++;
}
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_NO_START_BIT,
/* bSetSTO */ E_AHI_SI_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 3\n");
#endif
return FALSE;
}
while(bAHI_SiMasterPollTransferInProgress());

#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(bTraceI2c, "i2c_BusWriteReg: Leave\n");
#endif
return TRUE;
}

In order to send data I used vAHI_SiMasterWriteData8() and bAHI_SiMasterSetCmdReg(), but the latter is always stuck in while(bAHI_SiMasterPollTransferInProgress()); this step. Can you tell me any loopholes? What else do I need to do for I2C communication?mario_castaneda dheerajsawant

标记 (3)
0 项奖励
1 回复

670 次查看
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi,

Could you please look at the I2C pins? Are they in pull up?

Did you capture the frame with a logic analyzer?

Is the first bAHI_SiMasterPollTransferInProgress when the routine stops?

Regards,

Mario

0 项奖励