sergei94 0 25 ноября, 2020 Опубликовано 25 ноября, 2020 · Жалоба 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. GPIO_PinModeSet(gpioPortC, 10, gpioModeWiredAndPullUp, 1); GPIO_PinModeSet(gpioPortC, 11, gpioModeWiredAndPullUp, 1); #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); } } } Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
aaarrr 63 25 ноября, 2020 Опубликовано 25 ноября, 2020 · Жалоба Встроенные pull-up резисторы никоим образом не годятся для I2C. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
rx3apf 0 25 ноября, 2020 Опубликовано 25 ноября, 2020 · Жалоба For 100 kbps I2C data rate, use external 10 kOhm resistor, internal pull-up resistor too big (scope probe capacitance further increases the duration of the rising edge !) Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
sergei94 0 26 ноября, 2020 Опубликовано 26 ноября, 2020 · Жалоба The schematics of the board shown bellow. there is an intresting point TS3A4651 is a switch. my SCL and SDA outputs are SCL PortC 10 ,and SDA is PortC 11 by the datshee bellow. But i dont know where in my ports on the schemtics? How i connect these pullup to them?(if this is the correct solution) https://www.silabs.com/documents/public/schematic-files/WSTK-Main-BRD4001A-A01-schematic.pdfhttps://www.silabs.com/documents/public/data-sheets/efr32fg14-datasheet.pdf Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
sergei94 0 26 ноября, 2020 Опубликовано 26 ноября, 2020 · Жалоба How do know that i need to connect extra small pullups?How i see that SCL is too bad?Thanks. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
rx3apf 0 26 ноября, 2020 Опубликовано 26 ноября, 2020 · Жалоба An external pull-pullup (~ 10 K @ 100 kbps) should be connected from the side of the control controller rather than from the sensor. There is no need for any special control of the waveform - with the right pull-up choice there should be no problems. It is a mistake to rely on built-in pull-ups (their value is unacceptably high for i2c). Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
sergei94 0 26 ноября, 2020 Опубликовано 26 ноября, 2020 · Жалоба I understand.Thank you very much. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
MrBearManul 0 27 ноября, 2020 Опубликовано 27 ноября, 2020 · Жалоба 7 часов назад, sergei94 сказал: How i see that SCL is too bad? Подключите внешние резисторы 4.7 - 10 кОм. Правильно настройте ваш модуль I2C: скорость, филтры, если есть. Запустите непрерывный обмен данными и проконтролируйте осциллографом форму сигналов SCL и SDA. У них должны быть крутые фронты, не должно быть звонов (затухающих колебаний) на фронтах. После этого можно считать, что аппаратно шина исправна. Хотя, как правило, эти манипуляции не очень часто требуются. Обычно всё работает само собой Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
Tarbal 4 2 мая, 2021 Опубликовано 2 мая, 2021 · Жалоба That is expected if you are using pullups. The length of the front edge depends on the pullup and the line capacity. Nothing else may affects the edge length. It should operate properly with this kind of the edge. You may see that SCA front happens in the SDA acknowledge (actually NACK for the last byte) high state. First you got acknowledge. Second the clock edge is well after it got the value of 1. THAT IS HOW THE I2C OPERATES EVERYWHERE. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться