Why am I only receiving the first address byte? (I2C Protocol)

后端 未结 4 1736
南笙
南笙 2021-01-27 03:52

Expecting the slave to ACKnowledge and return data, but it does not. This is my protocol. This is my Datasheet

The datasheet mentions \"The slave will answer by sending

4条回答
  •  隐瞒了意图╮
    2021-01-27 04:10

    Your program has undefined behaviour. You have declared buffer as:

    char buffer[1];
    

    That's an array of one single character. The only null-terminated string you can possibly store there is empty string (i.e. where buffer[0] == '\0'). But you are using it to convert integers to strings.

    You need to make the buffer large enough to hold the largest string you expect to store in it, including the terminator.

提交回复
热议问题