This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C0 and I2C2 on TI-RTOS 2.12

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

  • Hi Tiago,

    Is there an error that you are getting?

    Steve
  • Hi Steve,
    Have no errors. I used the oscilloscope to verify, apparently the I2C is not initialized.
    Execution stops at line 33 (I2C_transfer...).
    My .cfg file -> docs.google.com/.../edit

    Tiago
  • Tiago,

    My colleague just informed me that there is a wiki page that gives an overview of the changes needed for migrating to TI-RTOS 2.12. I think this will help you. Please find that here:

    processors.wiki.ti.com/.../TI-RTOS_Migration_2_12

    Steve
  • Finally solved:

    just change EK_TM4C1294XL.c:

    FROM :
    /* I2C configuration structure, describing which pins are to be used */
    const I2CTiva_HWAttrs i2cTivaHWAttrs[EK_TM4C1294XL_I2CCOUNT] = { 
        { I2C7_BASE,INT_I2C7, ~0 /* Interrupt priority */},
        { I2C8_BASE, INT_I2C8, ~0 /* Interrupt priority */} 
    };
    TO:
    /* I2C configuration structure, describing which pins are to be used */
    const I2CTiva_HWAttrs i2cTivaHWAttrs[EK_TM4C1294XL_I2CCOUNT] = {
        {I2C0_BASE, INT_I2C0, ~0 /* Interrupt priority */},
        {I2C2_BASE, INT_I2C2, ~0 /* Interrupt priority */}
    };

    And init the I2C before "Board_initI2C();" on my main.c:

    /* 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);

    Tank you!

  • I have an application which needs access to pins PB2 and PB3 and I was struggling until I saw your post which helped me a great deal.

    Thank you,

    Russ