I2C acknowledge bit not sent.

JonasL
Posts: 13
Joined: Mon Nov 28, 2022 4:37 pm

I2C acknowledge bit not sent.

Postby JonasL » Sat Feb 25, 2023 8:37 am

Hello everyone,

I am trying to establish I2C communication between 2 microcontrollers. My colleague operates PIC32 as I2C master device and my job is to program ESP32S3 as I2C slave device. In my opinion our problem is synchronization but actually I have no clue. We both have written our codes separately and tested them out. I have recreated I2C communication scenario with ESP32S3WROOM-1 chip(slave) and ESP32DOITDEVKIT(master) and the slave device gets the bytes from the master device. I am providing logic diagram below(diagram1). My colleague has written an I2C application for LCD and it works fine, but when the same code is applied to our application(PIC32->ESP32S3) logic diagram does not seem fine to me. I am providing logic diagram below(diagram2) which represents PIC32->ESP32S3 I2C communication. Note, that after NACK data byte is still sent and because no ACK bite is sent, SCL keeps the low state. I am also adding my I2C slave code which works in my personal I2C simulation scenario. Maybe you guys can point out flaws in my code.
Attachments
i2c_slave_code.txt
(3.84 KiB) Downloaded 164 times
diagram1.png
diagram1.png (89.05 KiB) Viewed 1306 times
diagram2.png
diagram2.png (63.75 KiB) Viewed 1306 times

MicroController
Posts: 1724
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: I2C acknowledge bit not sent.

Postby MicroController » Sat Feb 25, 2023 11:08 pm

Not specific to the I2C communication, but in your code
1. you try to read up to 20 bytes into a buffer of 2 bytes.
2. you create the queue in one task while another task is supposed to read from it, and you create a new queue in each iteration (without ever deleting it...)

Who is online

Users browsing this forum: No registered users and 82 guests