Other Parts Discussed in Thread: ENERGIA, BQ76920
Hello All,
I am trying to write some data on EEPROM using I2C. For this i am using i2c0 (pb2, pb3 pins).
i am using Energia IDE and written below code.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_gpio.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/gpio.h"
#include "driverlib/pwm.h"
#include "driverlib/i2c.h"
#include "driverlib/uart.h"
#define address 0x50
void setup()
{
// put your setup code here, to run once:
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
GPIOPinConfigure(/*GPIO_PB2_I2C0SCL*/0x00010803);
GPIOPinConfigure(/*GPIO_PB3_I2C0SDA*/0x00010C03);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
I2CMasterSlaveAddrSet(I2C0_BASE,address, false);
while(I2CMasterBusBusy(I2C0_BASE) != false)
{
;
}
I2CMasterDataPut(I2C0_BASE, 0x400);
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusBusy(I2C0_BASE) != false)
{
;
}
if(I2CMasterErr(I2C0_BASE) == I2C_MASTER_ERR_NONE)
{
I2CMasterDataPut(I2C0_BASE, 'B');
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusBusy(I2C0_BASE) != false)
{
;
}
I2CMasterDataPut(I2C0_BASE, 'I');
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
}
else
{
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_ERROR_STOP);
}
}
void loop()
{
// put your main code here, to run repeatedly:
}
But problem is that nothing is appering on I2C SCL line. i mean SCL line always stay HIGH, i am watching SCL line using oscilloscope.
As far As i know when we start data transmission SCL line stay low until data transmission stops(correct me if i am wrong).
so, kindly suggest how can i solve this issue.