-
Notifications
You must be signed in to change notification settings - Fork 56
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
Why CH32V003J4M6 analogRead() not working ??? #141
Comments
In my fan controller project I have ADC working on the SOP8 CH32V003J4M6. It uses A0 (PA2) to read analog values. First some questions for you:
Please also read issue #110 for much info about using ADC. It has an example demonstrating proper use of ADC. Good luck! |
void loop() { Serial : BUT when i connet điều khiển của tôi, tôi có ADC hoạt động trên SOP8 CH32V003J4M6. Nó sử dụng A0 (PA2) để đọc các giá trị tương tự. Trước đó, có rất nhiều câu hỏi dành cho bạn:
void loop() { Serial : BUT when i connect pin A0 to the ground or Vcc, this not
My english not good, sorry sir :( |
Fortunately we have Google Translate to the rescue! Your example code looks fine. Just now I flashed it on a J4M6 and for me it works fine. I get zeros when connecting PA2 to GND and 1023 when connecting to 5V. Nice varying values in between when connecting to an NTC thermistor and wild values when disconnected. NOTE: after using serial on the SOP8 chip, you can flash it only once and then you will need to use the WCH-LinkUtility on the LinkE to Clear all code flash - by power off I suggest you to check your connections and make sure to copy the latest commits of the master branch over the 1.0.4. files. After enabling ADC you must also empty your build folder to force recompilation of the core code. |
:((
this return Zero . /* ENABLE Peripherals */ this return this not change when connecting GND or VCC ( 5v )
5V usb to vcc CH32v003j4m6
void loop() { ok, up load. I don't know ? why erro :(((( |
Sirrrrrrrrrrr, A0 not working. But use A2 (pin 7) working :V and I think A0 (pin 3) error |
That's very interesting. Good to know you have something working. In issue #110, you can read about a similar problem. The OP had problems using PA2 because that pin is also used for external crystal. In this entry some solution was mentioned. After selecting the proper clock from the clock selection menu (48MHz internal) it should work. Please check your clock setting and make sure there is no old header file with an override to this setting. If it still doesn't work I suggest you to try a different chip to make sure this one isn't defective and perhaps you should also try the other packages (SOP16/TSSOP20). |
OMGGGGGGGGGGGGG, I can fix that, I can use A0, A2 on ch32v003j4m6. Thank sirrr |
So you have it working now? Was it the clock setting? (Btw. issue #94 is another similar case. I guess you're not alone...) |
yesss |
I tried everything but couldn't ?
analogRead(PA_2) ?
analogRead(PA2) ?
all all return 0 :(((
but when i use it digitalWrite(PA2) this not output 3.3v !!!
plssss help meeeeeeee
The text was updated successfully, but these errors were encountered: