Hi,
I want to experience i2c communication and simplly read a value from the sensor. I wrote a code but it seams it does not work. Here is the i2c pice of code;
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
HWREG(I2C0_BASE + I2C_O_MCR) |= 0x01;
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
I2CMasterSlaveAddrSet(I2C0_BASE, 0x77, false);//Here slave address configured in write mode of master
I2CMasterDataPut(I2C0_BASE,0xAA);//0xAA put to transmision
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);// and sent
I2CMasterSlaveAddrSet(I2C0_BASE, 0x77, true);//read mode
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);// receive data comes from slave
Register 0xAA refers to a calibration constant, I just want to read to be sure it communicates in proper way.
When I put 0xAA in debuger mod I am checking the MDR register but it contents does not change with 0xAA where is the mistake what should be the right way of doing such thing.
I already red looked to 3 i2c example files and wrote this, but it doesnt work.
Thansk for reading.