cancel
Showing results for 
Search instead for 
Did you mean: 

I2C not working on STM8S103K3P6. what am I doing wrong?

Rita Jonkute
Associate II
Posted on November 15, 2017 at 16:25

The original post was too long to process during our migration. Please click on the attachment to read the original post.
7 REPLIES 7
Pavel A.
Evangelist III
Posted on November 22, 2017 at 14:43

What exactly is not working? Do you have the same issue as in this thread ?

https://community.st.com/0D50X00009XkafxSAB

-- pa

Posted on November 22, 2017 at 15:10

0690X00000608tNQAQ.png

First, somehow DR (data register is not showing anything), I clean ADDR by reading SR1 and SR3, clean TXE by writing DR twice, but can't get any data to buffer from MXL90614 temperature sensor

Posted on November 22, 2017 at 20:44

Well, the code *may be* correct - though it does not use the official STM library for i2c and system clock.

You need to hook a logic analyzer on i2c lines and see what the host sends and what the sensor answers.

-- pa

Posted on November 22, 2017 at 20:48

Sure.

It send this. Though according to manual I send DR 2times to clear txe. Address of device 0x5A

.0690X00000608qPQAQ.png

Posted on November 22, 2017 at 21:56

This is a write command because the lowest bit of the address byte (0xB4) is 0. To read, set the lowest bit to 1 (0xB5).

-- pa

Posted on November 22, 2017 at 22:22

Shouldn't first I send something to slave - sensor, in order to read what data it should send to the stm8s103?

Posted on November 24, 2017 at 14:57

The commands should be explained in the sensor's documentation.

-- pa