Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two-byte I2C reads #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix two-byte I2C reads #53

wants to merge 1 commit into from

Conversation

wezm
Copy link

@wezm wezm commented Mar 16, 2023

Second version of #52

I have a VEML6075 UV sensor hooked up to a Longan Nano, which uses 16-bit values for each register. As soon as the first 16-bit read was attempted the master was not sending ACK after the first byte. A lot of debugging later I think I found the source of the issue. In the GD32VF103 user manual (page 366) it says the following for when the number of bytes to read is 2:

In Step 2, software should set POAP bit before set START bit. In Step 4, software should
reset ACKEN bit before clearing ADDSEND bit. In Step 5, software should wait until BTC is
set and then set STOP bit and reads I2C_DATA twice

The code was setting a different bit related to checksums. I have made changes according to the user manual and this example from the C GD32VF103_Firmware_Library and I'm now able to read from the sensor properly.

Toggle the POAP bit instead of PECEN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant