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.

CCS/TM4C1294NCPDT: Problem with i2c on TM4C1294

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hello , 

I am just begining of this card software . I have a problem with i2c . I just wanna make sure i2c pin are activated or note . I mean my codes are right or not . I just follow code flow from Using Feature Set of I2C Master on TM4C129x . 

My goal is to control i2c pins are working . Thats why I just do step : Configuration of IO’s . My problem is pins are not activated . I just control SCL pin . I need to get clock graph on oscilloscope . But I cant . My code is below ;

Note that : I just wanna check 2 port they are working or not . 

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"

/**
 * main.c
 */
int main(void)
{

    //Enable GPIO for Configuring the I2C Interface Pins
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    //
    // Wait for the Peripheral to be ready for programming
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB)
    || !SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOL));
    //
    // Configure Pins for I2C2 Master Interface
    //
    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
    //
  
    //
    GPIOPinConfigure(GPIO_PL1_I2C2SCL);
    GPIOPinConfigure(GPIO_PL0_I2C2SDA);
    GPIOPinTypeI2C(GPIO_PORTL_BASE, GPIO_PIN_0);
    GPIOPinTypeI2CSCL(GPIO_PORTL_BASE, GPIO_PIN_1);
	return 0;
}

  • Do you have pullup resistors on SDA and SCL? I2C does not work without the pullup resistors. Also, you won't see any activity on the I2C pins until you finish the module configuration and try to transmit or receive.
  • Yes , pull up is needed on SDA and SCL lines. Without pull up you will get sawtooth like waveform on SCL. By putting 2.2K pull up on SCL problem can be solved.

    Regards,
    Digvijay
  • Hi Bob ;
    Can I use LED's in terms of slave device ? I can just send 1 and 0 .

    Thank you .
  • I am sorry. I do not understand your question. Perhaps you can show a schematic of what you have attached to the I2C2SCL and I2C2SDA lines.
  • digvijay khambe said:
    Without pull up you will get sawtooth like waveform on SCL.

    Really?   As the I2C output is, 'Open Drain' - what voltage source (then) enables such 'sawtooth?'       The 'conclusion'  - of a  'sawtooth-like waveform'  -  regularly resulting from a 'floating' I2C pin configuration - is improper.     (we don't doubt that 'you' observed such - yet that (near) sawtooth - most likely - resulted from (other elements) w/in your board or application - and proves NOT a 'general diagnostic PROOF' of a floating I2C pin!)

    digvijay khambe said:
    By putting 2.2K pull up on SCL problem can be solved.

    There is NO magic in 2K2 (and only 2K2!)     Such may prove useful in a heavily loaded I2C bus - which is 'not' this poster's use case.   (yet)

    As review of poster's code clearly shows (and as noted by vendor's Bob) the I2C initialization is incomplete - and no 'I2C' transmission has been commanded - thus his problem is 'beyond' missing pull-ups...   Note too - poster has failed to advise as to the 'presence' of pull-up resistors...

  • I mean that it will be slave device If I use LED's on SDA and SCL lines ? After Module Configurations , Transmissions to LED's and Receiving Data from Master
  • If I may (as many are the times firm/I have deployed Leds to enable the (basic) monitoring of signal lines):

    • an Led w/anode connected to the signal pin, cathode to Gnd. (and including a series resistor) - provided your data rate is (slow) enough - can confirm the presence of a 'logic-high.'
    • reversing that Led's 'connection polarity' - likewise - can then confirm the presence of a 'logic-low.'
    • Led's prove 'unable' to originate or send data to your MCU.    
    • the smallest capacity, simplest, I2C based EEProms - enable your (greatly) eased test & verification of your MCU's I2C port.     Starting w/a complex I2C device most always - leads to 'pain/frustration' - suffered by you (and by helper crüe - here)...

  • No, using LED's to identify the state of the I2C lines is not likely to work. The signals change too quickly. Use an oscilloscope or logic analyzer instead.