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.

Using PD1 and PD0

Hello,

Im working with tm4c123gxl, for my uni project, while in it, im using i2c and usb. ive successfully been able to work with the usb port and the i2c ports except than i2c3 (D0,D1), im not using any of the other gpio in port b (B7,B6) who connected to d also) can anyone help me to think what may be the problem??

thanks. 

  • Hello Doron,

    First of all it would be good to remove the connection between the two ports by removing the resistors.

    Secondly can you describe what is not working
    1. I2C requires pull up, have you got pull up on the I2C3?
    2. Configuration of the interface (no code in the original post)?

    Regards
    Amit
  • thanks amit for the quick answer,

    1. im using pull up resistors.

    2. i can add the code but i think  its less relevant (i will add it later). as i mention before, the communication with the usb and i2c is working fine, the *problem only occurs while im using i2c3 (PD0,PD1), because of the "uniqueness" of this port i thought there is a special set up or something i should do, but didnt find any in my search.

    3. i will try ur suggestion, to remove the connection.

    4. *the problem: while initializing the i2c3 the code jump to fault handler (because of hard fault) and stuck in the do nothing while.(not appearing in any of the other i2c - i2c0,i2c1,i2c2 - ive checked them individually).

    Regards,

    Doron.

  • Resistors Amit spoke to are, "R9 & R10" which marry PD0 (and another) to Port B. While I doubt these are solely responsible for your hard fault - at some point you'll have to "pull them" to liberate PD0 from its (shotgun) wedding to (unworthy) Port B.

    Have you (really) initialized Port D and I2C3 - a "miss" here leads directly to the dreaded "fault handler."

    I2C always demands proper, external pull-up resistors - which do not appear on many (most) such low cost eval boards.

  • Hello Doron

    Then you definitely need to share the code. It seems that the code has not initialized a peripheral. On how to debug a Fault, there are some details mentioned in the post link below.

    e2e.ti.com/.../374640

    Regards
    Amit
  • hey, here is the relevant parts in the code: (the code crashes during "GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);", when the bus=2 the code works fine)

    void SensorInit(int bus)

    {

    switch (bus)

    {

    case 2:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);

    SysCtlPeripheralReset(SYSCTL_PERIPH_I2C2);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    GPIOPinConfigure(GPIO_PE4_I2C2SCL);

    GPIOPinConfigure(GPIO_PE5_I2C2SDA);

    GPIOPinTypeI2CSCL(GPIO_PORTE_BASE, GPIO_PIN_4);

    GPIOPinTypeI2C(GPIO_PORTE_BASE, GPIO_PIN_5);

    I2CMasterInitExpClk(I2C2_BASE, SysCtlClockGet(), false);

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x0F, 0x10); 

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x2A, 0x2A);

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x2A, 0x01); 

    break;

    case 3:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);

    SysCtlPeripheralReset(SYSCTL_PERIPH_I2C3);

    GPIOPinConfigure(GPIO_PD0_I2C3SCL);

    GPIOPinConfigure(GPIO_PD1_I2C3SDA);

    GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);

    GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);

    I2CMasterInitExpClk(I2C3_BASE, SysCtlClockGet(), false);

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x0F, 0x10); 

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x2A, 0x2A); 

    I2CSend(bus, SLAVE_ADDRESS, 2, 0x2A, 0x01); 

    break;

    }

    return;

    }

    /////////////// part of the main:

    int main(void)

    {

    //////////////////////////////////////////////////////////////////////////////INITIALIZE

        uint16_t ui16ButtonsChanged, ui16Buttons;

        bool bUpdate;

        uint8_t bus[4]={0,1,2,3};

        ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |

                           SYSCTL_XTAL_16MHZ);

        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

        g_iGamepadState = eStateNotConfigured;

        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

        SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);

        ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_AHB_BASE, GPIO_PIN_4 | GPIO_PIN_5);

        SensorInit(bus[3]);  

    /////////////////////.................

    thanks.

  • solve the problem! 

    in the link with the tips ive found that  APB DISABLED After setting AHB mode,


    so because usb init. also on port D i had to change the mode for the (to AHB) i2c3.

    thanks for the help.

  • Looking quickly - "SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);" appears unique to your, "crashing use of Port_D."

    Have you tried removing that bus "enhancement" from Port_D - to see if that indeed proves the source of your issue?

    BTW - your use of "parallel code listings" - altering only the peripheral selection parameters - is quite good and should be followed by others.    I should note that, "cut and paste" should be employed here - to prevent the "hard to find" typos which are admitted when typing - rather than cut/paste - is employed.

    In addition - these 2 lines may deserve test/verify maybe modification:

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);

    My small firm does not use this vendor's AHB bus often enough to know if those 2 lines are, "legal."

    [edit:  Our posts crossed - yet we reached the same conclusion!   (always good that)]

  • Hello Doron

    You are welcome. Also as mentioned in the "Tips", there is one for debugging basic Bus Fault, that can land the code into a FaultISR. That should be useful as well.

    Regards
    Amit