Skip to main content
Associate III
April 22, 2024
Question

i2c

  • April 22, 2024
  • 4 replies
  • 3511 views

Hi,

I now implementing i2c with 2 stm board.

The process is 

1. Master transmit data 

2. Slave receive and calculate some functions.

3. Slave transmit that changed data

4. Master receive it.

with HAL_I2C functions.

 

 

I measure the SDA line with logic analyzer, and the results are unexpected..

As you can see in the code, I transmitt 3.1416 to slave repeatedly.

and in the slave ProcessData function, TX_Buffer_1 updated 1 or 0.111 randomly . (random but the probability of 1 must be higher than 0.111)

As a result , the very first data transmit & receive & calculate & transmit well (left picture)

but after that, every data show 0.111 (right one)

eunni_0-1713786857592.png

I check RX_Buffer_1 in slave with PuTTY,

RX_Buffer _1 printed

3.1416

0

0

0

0

... which means except first data, slave receive 0 everytime...

but master still transmit 3.1416 (I checked it both logic analyzer and PuTTY)

 

Plz help :( idk what's the problem....

I attached master and slave main.c file. thank you

 

summary----------------------------------------------------------

1. master transmit 3.1416 reapetedly

2. slave receive 3.1416 at first, but after that, slave receive 0.

    This topic has been closed for replies.

    4 replies

    Andrew Neil
    Super User
    April 22, 2024
    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    eunniAuthor
    Associate III
    April 22, 2024

    I'm sorry :( 

    After I posted it, I thought it was mass, so I re-post.

    I can't find edit or delete function here 

    Andrew Neil
    Super User
    April 22, 2024

    @eunni wrote:

    I can't find edit or delete function here 


    It's here - the little round "down-arrow" in the top-right of the post:

    AndrewNeil_0-1713800192943.png

     

    EDIT:

    For the opening post of a thread, it has 'Edit Message' instead of 'Edit Reply':

    AndrewNeil_1-1713800325383.png

    That also lets you edit the title.

     

     

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.