This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LM3S9B92 I2C not work

The following codes doesn't work, don't know why?
please point out the faults, thanks.

***********************************************
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet();, true);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3 );
I2CMasterEnable(I2C0_MASTER_BASE);
while(1)
{ while(I2CMasterBusBusy(I2C0_MASTER_BASE)) ; I2CMasterDataPut(I2C0_MASTER_BASE, 'U');
} *************************************************

Parents Reply Children
  • As Jack said,

    I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet();, true);
    

  • Sorry, I typed wrong, not the the second last
    semicolon, actually,

    this codes is testing on LM3S9B92 Eval board,
    the following functions are in a libarry, TI don't
    provide the sample code for operating I2C,

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), true);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3 );
    I2CMasterEnable(I2C0_MASTER_BASE);
    while(1)
    { while(I2CMasterBusBusy(I2C0_MASTER_BASE)) ; I2CMasterDataPut(I2C0_MASTER_BASE, 'U');
    }

  • Start posting your code correctly formatted with the pre tags as clearly described just above the message input box.

    Then, we will be able to see on the indentation if a while loop is expected to be empty, or if it is expected to control the execution of a following statement.

    Right now, your code is unreadable. When posted, it should look like:

    #include <stdio.h>
    
    int main(void) {
        printf("Hello world!\n");
        return 0;
    }