Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 2 months ago.
Why Nucleo-F072B I2C no any response and out when use the compiler example program?
Maybe this is the story about ST's I2C...........................
What program are you running on the board? Just basic I2C? Which pins are you using?
posted by Jan Jongboom 10 Aug 2016I2C i2c(I2C_SDA, I2C_SCL);
DigitalOut myled(LED1);
Serial pc(SERIAL_TX, SERIAL_RX);
volatile char TempCelsiusDisplay[] = "+abc.d C";
int main() {
char data_write[2]; char data_read[2];
/* Configure the Temperature sensor device STLM75: - Thermostat mode Interrupt - Fault tolerance: 0
while (1) {
i2c.read(LM75_ADDR, data_read, 4, 0);
Calculate temperature value in Celcius int tempval = (int)((int)data_read[0] << 8) | data_read[1]; tempval >>= 7; if (tempval <= 256) { TempCelsiusDisplay[0] = '+'; } else { TempCelsiusDisplay[0] = '-'; tempval = 512 - tempval; }
Decimal part (0.5°C precision) if (tempval & 0x01) { TempCelsiusDisplay[5] = 0x05 + 0x30; } else { TempCelsiusDisplay[5] = 0x00 + 0x30; }
Integer part tempval >>= 1; TempCelsiusDisplay[1] = (tempval / 100) + 0x30; TempCelsiusDisplay[2] = ((tempval % 100) / 10) + 0x30; TempCelsiusDisplay[3] = ((tempval % 100) % 10) + 0x30;
Display result pc.printf("temp = %s\n", TempCelsiusDisplay); myled = !myled; wait(1.0); }
}
posted by Jason Wang 10 Aug 2016The program generate by mbed. And the pin is D14/D15
posted by Jason Wang 10 Aug 2016