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'); } *************************************************
please point out the faults, thanks
You didn't explain in what way the code doesn't work, but I'd say it's a fair bet that you don't want the second last semicolon.
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; }