yefj
Advanced Member level 5
Hello ,I want to communicate with my SI7021 with I2C drive of silicon labs using efr32fg14.
From the useguide manual shown bellow i got the ports needed.
API from the link bellow Was used to write a code as shown bellow.
SCL and SDA are running on my four scope photos as shown bellow,So something is active there.I cant recognise the patterns shown of the data sheet shown bellow from the scope.I tried to use the debugger but it showed me BLANK "" value of buf variable on every step no matter what as shown in the printscreen bellow.
How can i see the scope photos and recognise the meening of what going on from the data sheet diagram?
Thanks.
1st scope
2nd scope
3rd scope
4th scope
From the useguide manual shown bellow i got the ports needed.
API from the link bellow Was used to write a code as shown bellow.
SCL and SDA are running on my four scope photos as shown bellow,So something is active there.I cant recognise the patterns shown of the data sheet shown bellow from the scope.I tried to use the debugger but it showed me BLANK "" value of buf variable on every step no matter what as shown in the printscreen bellow.
How can i see the scope photos and recognise the meening of what going on from the data sheet diagram?
Thanks.
I2CEMLIB - v5.4 - MCU EFR32FG14 API Documentation Silicon Labs
docs.silabs.com
1st scope
2nd scope
3rd scope
4th scope
Code:
#include "stddef.h"
#include "em_system.h"
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "em_gpio.h"
#include "i2cspm.h"
#include "si7013.h"
#include "sl_sleeptimer.h"
#include "graphics.h"
#include "em_adc.h"
#include "bspconfig.h"
uint8_t com1[1] = {0xE3};
uint8_t i2c_rxBuffer[3];
int main(void)
{
I2C_TransferSeq_TypeDef i2cTransfer;
I2C_TransferReturn_TypeDef result;
I2CSPM_Init_TypeDef i2cInit = I2CSPM_INIT_DEFAULT;
/* Chip errata */
CHIP_Init();
// Enabling clock to the I2C, GPIO, LE
CMU_ClockEnable(cmuClock_I2C0, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_HFLE, true);
// Starting LFXO and waiting until it is stable
CMU_OscillatorEnable(cmuOsc_LFXO, true, true);
I2CSPM_Init(&i2cInit);
// In order to enable the I2C0_SCL function in PC10 you need to use ROUTE 14
// In order to enable the I2C0_SDA function in PC11 you need to use ROUTE 16
//Also note that there's a GPIO pin PD15 that need to be set to high in order to route the signals to the sensor,
// Using PC10 (SCL) and PC11 (SDA)
GPIO_PinModeSet(gpioPortC, 10, gpioModeWiredAndPullUp, 1);
GPIO_PinModeSet(gpioPortC, 11, gpioModeWiredAndPullUp, 1);
//Si7021 switch on
GPIO_PinModeSet(gpioPortD, 15, gpioModePushPull, 1);
// Enable pins at location 15 as specified in datasheet
I2C0->ROUTEPEN = I2C_ROUTEPEN_SDAPEN | I2C_ROUTEPEN_SCLPEN;
I2C0->ROUTELOC0 = (I2C0->ROUTELOC0 & (~_I2C_ROUTELOC0_SDALOC_MASK)) | I2C_ROUTELOC0_SDALOC_LOC16;
I2C0->ROUTELOC0 = (I2C0->ROUTELOC0 & (~_I2C_ROUTELOC0_SCLLOC_MASK)) | I2C_ROUTELOC0_SCLLOC_LOC14;
i2cTransfer.flags=I2C_FLAG_WRITE_READ;
i2cTransfer.addr=0x80;//address with write
i2cTransfer.buf[0].data=com1[0]; // Measure Temperature, Hold Master Mode
i2cTransfer.buf[0].len=2; //2 bytes length
i2cTransfer.buf[1].data=i2c_rxBuffer;
i2cTransfer.buf[1].len=3; //LS MS checksum
while(1)
{
result=I2C_TransferInit(I2C0,&i2cTransfer);
// Sending data
while (result == i2cTransferInProgress)
{
result = I2C_Transfer(I2C0);
}
}
}