I am working with a colleague on a personal project, a home-made bluetooth speaker powered by NXP microcontroller LPC1343 and TFA98xx Audio Amplifier, together with a BT module by Qualcomm.
The application is quite simple: the BT module provides I2S signals to the amplifier, LPC uC takes care of initializing it from I2C interface.
We are facing some problems to make the I2C reading/writing working. We are using MCUXpresso 10.2.1, we loaded the LPCOpen library fror LPC1343 (lpcopen_2_05_lpcxpresso_nxp_lpcxpresso_1343.zip) and we used the example "periph_i2c" as starting point.
The I2C pins 14 (PIO0.4/SCL) and 15 (PIO0.5/SDA) don't show any kind of activity, we tried several boards and measured with an oscilloscope, they seem stuck.
Our goal at the moment is to read and write one I2C register of the TFA, for example register 0x3. If we will manage to do that, we could proceed with the rest, it will be pretty straight-forward.
We would like to have an example of main(), to replace the one of the LPCOpen example, able to initialize I2C bus with 400kHz speed, read the 16 bits of TFA register 0x3 and write the same register 0x3 with other 16 bits.
I2C address of TFA98xx slave device is 0x34
My colleague will provide tomorrow the source code we are trying to use, without success.
thanks in advance for your help,
Dario
I should point you to older discussions on this forum like I2C on LPC1343
The I2C samples are in general poorly written (Even old NXP employees say "eek") and the comments sometimes don't even match the software. So i thought it better to point you to the old discussions we had here some years ago. If you want a working example then i can point you to the website of Rob65 (old NXP employee who was active on this forum but stopped some years ago). The example is written for the LPC11xx but should show you how to write your own drivers. The website: MyVoice CAD/CAM Services - Free Software Projects .
Greetz,
Serge
The size of the transmit buffer is 0. But you need to transmit the address of the I2C slave. The processor stores the slave address in the tx buffer.
It is not the first time that this issue is raised here, to my understanding NXP should clarify this in the LPCopen documentation.
Hi All,
I am the colleague of Dario working on this project, we used the following code to test:
int main(void)
{
int tmp;
int xflag = 0;
static I2C_XFER_T xfer;
/* Generic Initialization */
SystemCoreClockUpdate();
Board_Init();
i2c_app_init(I2C0, SPEED_100KHZ);
/* Simulate an EEPROM slave in I2C0 */
i2c_eeprom_init(I2C_EEPROM_BUS);
xfer.slaveAddr = 0x34;
xfer.rxBuff = 0;
xfer.txBuff = 0;
xfer.txSz = 0;
xfer.rxSz = 2;
tmp = Chip_I2C_MasterRead(i2cDev, xfer.slaveAddr, xfer.rxBuff, xfer.rxSz);
return 0;
}
I2C pull-up resistors are in place but we still cannot see any activity on the I2C lines , any idea ?
Also about this i2c_eeprom_init(I2C_EEPROM_BUS); this is used for EEPROM read as follows ,
I just modified I2C_SLAVE_EEPROM_ADDR to be our TFA98XX address, anything else must be also changed ?
static void i2c_eeprom_init(I2C_ID_T id)
{
memset(&seep_data[1], 0xFF, I2C_SLAVE_EEPROM_SIZE);
seep_xfer.slaveAddr = (I2C_SLAVE_EEPROM_ADDR << 1);
seep_xfer.txBuff = &seep_data[1];
seep_xfer.rxBuff = seep_data;
seep_xfer.txSz = seep_xfer.rxSz = sizeof(seep_data);
Chip_I2C_SlaveSetup(id, I2C_SLAVE_0, &seep_xfer, i2c_eeprom_events, 0);
}
Thanks in advance.
Mehdi
Are the pull-up resistors present on the I2C lines? These are open collector en without those resistors you won't see any signal.