Other Parts Discussed in Thread: TM4C1294NCPDT
Hi, I'm porting my project from TIRTOS 2.00.02.36 and NDK 2.23.01.01 to TIRTOS 2.12 (last version for my EK-TM4C129XL - TM4C1294NCPDT).
I use I2C0(PB2/PB3) and I2C2(PN5/PN4), but in EK_TM4C1294XL.c > EK_TM4C1294XL_initI2C, only I2C7 and I2C8 are initialized.
I tried this on main.c ( no success):
/* * Inicialização da I2C */ // /* I2C0 Init */ /* Enable the peripheral */ SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); /* Configure the appropriate pins to be I2C instead of GPIO. */ GPIOPinConfigure(GPIO_PB2_I2C0SCL); GPIOPinConfigure(GPIO_PB3_I2C0SDA); GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); /* I2C2 Init */ /* Enable the peripheral */ SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2); /* Configure the appropriate pins to be I2C instead of GPIO. */ GPIOPinConfigure(GPIO_PN5_I2C2SCL); GPIOPinConfigure(GPIO_PN4_I2C2SDA); GPIOPinTypeI2CSCL(GPIO_PORTN_BASE, GPIO_PIN_5); GPIOPinTypeI2C(GPIO_PORTN_BASE, GPIO_PIN_4);
Board_initI2C();
In old version, all work correctly.
For example, i use I2C here:
/**
* Le os valores do RTC e escreve na memoria apontada por *read
*/
Bool lerRTC(char *read) {
#define READ_COUNT 7
UInt peripheralNum = 0; /* Interface I2C0 */
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
UChar writeBuffer[9];
writeBuffer[0] = 0;
UChar readBuffer[READ_COUNT];
Bool transferOK;
I2C_Params_init(&i2cParams);
i2c = I2C_open(peripheralNum, &i2cParams);
if (i2c == NULL) {
printf("Nao foi possivel abrir a interface I2C0!\n");
fflush(stdout);
I2C_close(i2c);
return false;
}
//Seta os parametros para a comunicacao
i2cTransaction.slaveAddress = 104; /* 7-bit peripheral slave address */
i2cTransaction.writeBuf = writeBuffer; /* Buffer to be written */
i2cTransaction.writeCount = 1; /* Number of bytes to be written */
i2cTransaction.readBuf = readBuffer; /* Buffer to be read */
i2cTransaction.readCount = READ_COUNT; /* Number of bytes to be read */
//Comunica com o dispositivo
transferOK = I2C_transfer(i2c, &i2cTransaction);
if (!transferOK) {
I2C_close(i2c);
wdOpen(wdEthernet, 1000);
return false;
}
//converte os valores lidos e escreve na memoria do microcontrolador
read[0] = bcd2dec(readBuffer[3]); //dia da semana
read[1] = bcd2dec(readBuffer[4]); //dia
read[2] = bcd2dec(readBuffer[5]); //mes
read[3] = bcd2dec(readBuffer[6]); //ano
read[4] = bcd2dec(readBuffer[2]) & 0x3f; //hora
read[5] = bcd2dec(readBuffer[1]); //minuto
read[6] = bcd2dec(readBuffer[0]) & 0x7f; //segundo
I2C_close(i2c);
return true;
}
How i use I2C0 on new version of TI-RTOS?
Att:
Tiago