Other Parts Discussed in Thread: TM4C1294NCPDT
Dear friends,
For the last month I have been learning and working on I2C protocol, theoretically everything is OK, but when I tried to apply my knowledge on the real board a problem which is gonna to lead me to crazy rised!!!
I always get strange things on the bus! I will put my code and the logic analyzer photo bellow.
I just want to say that I have tried almost everything to solve that!!! but no results. and note, that I tried loop back example and it worked. but my code didn't work :(
The details of the experiment: TIVA C Connected launchpad (TM4C1294NCPDT MCU) with two 4K7 pull up resistors on the clock and data buses connected with 5V from TIVA board.
- I tried to use both I2C0 and I2C2 modules with no results!
hope that you help me cuz I am totally disappointed :(
#include "inc/tm4c1294ncpdt.h"
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_i2c.h"
#include "driverlib/i2c.h"
#include "driverlib/rom.h"
#include "driverlib/pin_map.h"
#define SLAVE_ADDRESS 0x3C
void
InitConsole(void)
{
//
// Enable GPIO port A which is used for UART0 pins.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Configure the pin muxing for UART0 functions on port A0 and A1.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
//
// Enable UART0 so that we can configure the clock.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
//
// Select the alternate (UART) function for these pins.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
}
int
main(void)
{
uint32_t pui32DataTx;
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
GPIOPinConfigure(GPIO_PN5_I2C2SCL);
GPIOPinConfigure(GPIO_PN4_I2C2SDA);
GPIOPinTypeI2CSCL(GPIO_PORTN_BASE, GPIO_PIN_5);
GPIOPinTypeI2C(GPIO_PORTN_BASE, GPIO_PIN_4);
I2CMasterInitExpClk(I2C2_BASE, SysCtlClockGet(), false);
InitConsole();
I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS, false);
UARTprintf("I2C2 Initialized.\n");
pui32DataTx = '4';
I2CMasterDataPut(I2C2_BASE, pui32DataTx);
I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_SEND);
while(I2CMasterBusy(I2C2_BASE));
UARTprintf("Sent: '%c'\n", pui32DataTx);
return(0);
}
This is what I get on the buses with the previous code. Where is the address!!?? where is the data!! I just see start condition and then nothing !!!
Thank you in advance for your help :)






