Reputation: 309
I am using a cortex m3 based mc. I scoped my communication with a logic analyzer, but I don't really understand what I see. Can you help me?
On the following pictures you can see the address, but I think it s not correct or am I mistaking. There is no sensor wired to the mc yet, I changed the address to analyze.
adress 0x00, data 0x55 : https://i.sstatic.net/sdG0P.png
address 0x55, data 0x55: https://i.sstatic.net/sdG0P.png#1
address 0xff, data 0x55: https://i.sstatic.net/sdG0P.png#2
My code:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C7);
GPIOPinConfigure(0x00001002);
GPIOPinConfigure(0x00001402);
GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_5);
GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_4);
I2CMasterInitExpClk( I2C7Master_Base, SysCtlClockGet(), false);
I2CMasterSlaveAddrSet(I2C7Master_Base, 0xff, false);
I2CMasterDataPut(I2C7Master_Base, 0x55);
I2CMasterControl(I2C7Master_Base, I2C_MASTER_CMD_SINGLE_SEND);
while(I2CMasterBusy(I2C7Master_Base));
Can somebody give an explanation?
Upvotes: 1
Views: 168
Reputation: 1782
Indeed you better make a wired connection between master and light sensor. Then you need to send a proper address of the sensor which should be acknowledged by slave. You will see ACK-bit in the scope when the slave acknowledges on its address. Next you are going to operate with data according to the datagrams on the sensor - any data byte should be also acknowledged (most likely, or kind of due to datasheet). Start with wired connection because there is no big sense to try I2C bus without load, we can't even see 8-9 clock cycles on the diagram you posted because it is without load connection I think. Hope it helps.
Upvotes: 1