cancel
Showing results for 
Search instead for 
Did you mean: 

i2c communication on STM32F103RB

vmool
Associate

i want to read ADC MCP3425 digital data using i2c communication with Stm32f103rb nucleo-64 board . For programming of nucleo-64 i used arduino ide. 

1] Is it possible to modify default setting of MCU clock ? 

2]what is the default setting of i2c clock frequency? 

3]how to read single bit acknowledgement send by MCP3425 ADC? what's the instruction for that?

#include <Wire.h>

unsigned int HIGH_BYTE,LOW_BYTE;

unsigned int RECV_BYTE;

void setup()

{

 Wire.begin(); // join i2c bus

}

void loop()

{

 Wire.beginTransmission(0xD0); // transmit to device D0

 Wire.write(0X98);

 Wire.write(0XD1);  

 HIGH_BYTE = Wire.read();  // receive byte as an integer   

 LOW_BYTE = Wire.read();  // receive byte as an integer  

 RECV_BYTE = HIGH_BYTE;

 RECV_BYTE= (RECV_BYTE<<8)+LOW_BYTE;     

 Wire.endTransmission();  // stop transmitting

}

0 REPLIES 0