lpcware

LPC1347 I2C LPCOpen driver problem or bug [Solved/Alternative]

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by bjornenerdes on Thu Apr 10 02:32:35 MST 2014
While trying to migrate to LPCOpen 2.05 for LPC13xx I had trouble initiating the I2C driver Chip layer (NO_BOARD_LIB).

What I found was that the PRESETCTRL was not set:
LPC_SYSCTL->PRESETCTRL |= (0x1<<1);

Anyone having similar problems? Or am using it in the wrong way?

Now it is functioning with the following code in sysinit.c:


STATIC const PINMUX_GRP_T pinmuxing[] = {
{0,  4,  (IOCON_FUNC1 | IOCON_SFI2C_EN)},
{0,  5,  (IOCON_FUNC1 | IOCON_SFI2C_EN)},
};


And in main.c:

static uint8_t txBuffer[64];
static uint8_t rxBuffer[64];
void I2C_IRQHandler(void) {
if (Chip_I2C_IsMasterActive(I2C0)) {
Chip_I2C_MasterStateHandler(I2C0);
} else {
Chip_I2C_SlaveStateHandler(I2C0);
}
}
int main(void) {
// START Initializations =====================================================
// Clock init
if (SysTick_Config(SystemCoreClock / 1000)) {   /* Timer 1 msec interrupts  */
while (1);}
    // I2C Init
static I2C_XFER_T xfer;
LPC_SYSCTL->PRESETCTRL |= (0x1<<1);
    Chip_GPIO_Init(LPC_GPIO_PORT);
    Chip_I2C_Init(I2C0);
    Chip_I2C_SetClockRate(I2C0, 100000);
    Chip_I2C_SetMasterEventHandler(I2C0, Chip_I2C_EventHandler);
    NVIC_EnableIRQ(I2C0_IRQn);

    txBuffer[0] = 0x01;
    xfer.slaveAddr = 0x28;
    xfer.txBuff = txBuffer;
    xfer.txSz = 1;
    xfer.rxSz = 2;
    xfer.rxBuff = rxBuffer;
    Chip_I2C_MasterTransfer(I2C0, &xfer);
return(0);
}


Kind regards,

Björn

==========Solver/Alternative============

Instead of using Chip_I2C_Init(); use master version Chip_I2CM_Init();

Outcomes