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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,227 Views
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

Tags (3)
0 Kudos
Reply
1 Reply

1,052 Views
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 Kudos
Reply