Problematic Clock shape in I2C of efr32fg14

Thread Starter

yef smith

Joined Aug 2, 2020
146
Hello ,I am using efr32fg14 starter kit,i have defined gpio to be as shown bellow.I clock a rounded clock shape as shown in the print screen bellow.

I am already using pullup ressistor for my GPIO.
obviosly the rise time is too slow,i have added the full code bellow,what coul be done to make the clock shape better?

Thanks.




Code:
GPIO_PinModeSet(gpioPortC, 10, gpioModeWiredAndPullUp, 1);

  GPIO_PinModeSet(gpioPortC, 11, gpioModeWiredAndPullUp, 1);
1606324885907.png


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);

   }

}



 }
 

andrewmm

Joined Feb 25, 2011
1,010
As @MrChips says, use external pull ups , not the ones built on the processor,
GPIO pullups tend to be many 10 of K ohm, you need around 5K ohm,

Just one note though,
even though those edges are slow, the I2C should still work just fine,
if you have problems, then its something else
 

andrewmm

Joined Feb 25, 2011
1,010
Ok, so that's a different question,

The TS3A4751 is an analog switch,
where are you looking at the I2C signals,

what voltage to do you see on Vsensor and Vmcu ?
is sensor_enable constant 1 or 0 ?
 

Thread Starter

yef smith

Joined Aug 2, 2020
146
Last edited:

Ian0

Joined Aug 7, 2020
1,282
They go between SDA and Vcc and between SCL and Vcc.
Vcc can be either 3.3V or 5V, it doesn’t mind.
Usually they are the microcontroller end of the track.

What is the purpose of the analogue switch?
 

Thread Starter

yef smith

Joined Aug 2, 2020
146
I dont know what is the purpose,i just looking for ways to improve my CLK form.Ussualy i just define the GPIO and say what ports and pins.I dont know how to connect extra resistors in paralel.
 

Ian0

Joined Aug 7, 2020
1,282
Yes. It is essential. (and so is the one on SDA)
There are two reasons it is like that
1. So that it can connect between ICs on different supplies (3V, 3.3V, 5V etc.) so long as they share the same 0V.
2. So that it can accommodate slow peripherals. If the MASTER is going to fast, the slave can extend the clock pulse to slow it down. For that to be able to happen neither of them may pull the voltage high, but both of them can pull it low. Only the external resistor can pull it high.
It’s like “hang in a minute you’re talking too fast!”
Quite smart for something that’s been around almost 40 years.
 

Thread Starter

yef smith

Joined Aug 2, 2020
146
Ok , In my boards sensor i cant connect external resistor and its set for 100KHZ CLK
So should i lower the clock rate or increase the SCL rate to improve the shape?
Thanks.
 

JohnInTX

Joined Jun 26, 2012
4,376
You say right at the start
" obviously the rise time is too slow "

are we now in agreement that the I2C is just fine ?
It looks fine to me too. At the left of the screen there is an ACK followed by a 00h byte that is NAKed then the stoP condition and another Start condition. Looks like 100KHz I2C
 

Ian0

Joined Aug 7, 2020
1,282
If you reduce the frequency, all it does is move the edges further apart. The edges remain exactly the same.
You then increase the time base so that you get the same number of edges on screen. Then they will look better, but they won’t be any different.
 
Top