board707 / w80x_arduino

w806 package for Arduino IDE
GNU Lesser General Public License v2.1
68 stars 12 forks source link

The system crashes when ADC and hw i2c are used at the same time #39

Closed Chenjiek closed 3 months ago

Chenjiek commented 3 months ago

Thank you for helping me solve the problem. I am currently encountering a situation where the LED screen SSD1306 of U8G2 using PA1 and PA4 as hardware I2C freezes when reading the ADC voltage. You can use software to simulate I2C at other pins, but the refresh rate displayed is too slow. We look forward to resolving this issue soon. Thank you!

AnatolSher commented 3 months ago

你好 :) Replace these files in your Arduino package, test and tell us the result Change_this.zip

Chenjiek commented 3 months ago

Okay, I did a simple compilation and encountered an error. I will send the error message below: C:\Users\Administrator\AppData\Local\Arduino15\packages\w80x_duino\hardware\XT804\0.0.6\cores\w806\HardwareI2C.cpp:2:25: fatal error: HardwareI2C.h: No such file or directory

include "HardwareI2C.h"

                     ^

compilation terminated.

exit status 1

Compilation error: exit status 1

AnatolSher commented 3 months ago

Hi! If you are using Windows, you need to rewrite the files in the following folders: C:\Users\User\AppData\Local\Arduino15\packages\w80x_duino\hardware\XT804\0.0.6\libraries\Wire <- HardwareI2C.cpp C:\Users\User\AppData\Local\Arduino15\packages\w80x_duino\hardware\XT804\0.0.6\cores\w806 <- Arduino.c C:\Users\User\AppData\Local\Arduino15\packages\w80x_duino\hardware\XT804\0.0.6\cores\w806\lib\drivers <- wm_adc.c Where User - your login in Windows

Chenjiek commented 3 months ago

Okay, I found the path and it's already being compiled. Wait a moment, I'll give it a try..

AnatolSher commented 3 months ago

For maximum speed hw i2c image

Chenjiek commented 3 months ago

QQ图片20240429170436 MN5 Yes, I tested it for a long time just now and it seems that the conflict between AD input and I2C has been resolved. The screen refresh speed is very fast, which can be described as very, very beautiful. Thank you very much for your help. Thank you, but I have a question. Why is the lowest voltage of this ADC not 0V, but 19mv?

AnatolSher commented 3 months ago

Hmm... Very beautiful girl :)

To use ADC correctly, you need to study Chapter 26 of the datasheet for w80x chips. Individual calibration is required for accurate measurements. The calibration technique was described in a question on ask.winnermicro.com. I don't remember exactly. HAL provides simplified ADC management. More advanced control is implemented in the W800-SDK provided by WinnerMicro.

Chenjiek commented 3 months ago

Okay, it looks like some advanced knowledge. Thank you. This has already been completed. Do I also need to close it?

AnatolSher commented 3 months ago

Yes Good luck

board707 commented 3 months ago

Fixed in 5d60d5c