Pinguino PIC32-OTG - analogRead does not work anymore in Arduino IDE

Started by iz3gme, October 02, 2023, 09:01:32 PM

Previous topic - Next topic

iz3gme

I've recompiled an old project of mine with latest Arduino and after ours of debugging I'm pretty sure call to analogRead does not work any more (not for me at least  :-\ ).

To debug I used AnalogInOutSerial example from arduino ide, none of the analog input seems to work

To reproduce I follow this steps:
  • download a fresh ide (v 2.2.1)
  • installed board support (v 1.2.6)
  • open AnalogInOutSerial example
  • change analogInPin definition to A0 (or any other analog pin)
  • change analogOutPin definition to 13
  • upload to board
  • open serial monitor
  • connect A0 input to GND
  • move A0 pin connection from GND to 3.3v

Read values remains the same, apart a 1-2 digit flickering, no matter what you do in last two steps.

To test hardware I flashed back Pinguino boot loader and tested with the same example in Pinguino IDE where it works correctly, so I'm confident "magic smoke" is still in there.

For sure there must be something I'm doing wrong ... can any one do the same test and help me before I get crazy? :o

Thanks for any help

LubOlimex

Try with older Arduino IDE version, older than 2.0.0.

Make sure to post in the Arduino IDE forums for the issue, also search for similar issues with analog in and out examples. From what I read a lot of people complain about Arduino IDE version 2.0.0 and newer - a lot of stuff broke.
Technical support and documentation manager at Olimex

iz3gme

Thanks for your answer

I tested some more in deep and I found the problem to be version 1.2.6 of Olimex PIC boards support, using v 1.2.5 all is ok

I've done some test changing support library version back and forth using both arduino ide v 2.2.1 or older v 1.8.19 downgrading support library to 1.2.5 analog input works, upgrading to 1.2.6 and re-uploading the very same program they dont

I'll test with my original program later today

Best regards

Stanimir5F

Hello iz3gme and thank you for your feedback!

There was indeed a mistake I have made in the 1.2.6 version of the package.
In this version I have removed the macros: portRegisters, digitalPinToAnalog, analogInPinToChannel because it was reported that these are causing lots of warnings due to multiple (different) definitions of the macros. So I removed them from the board specific header (Board_Defs.h) and left the one that is general for all the boards (cores\pic32\pins_arduino.h lines 244, 248, 254, 258) but the mistake I did was that I didn't change the value of the macro and left what it was by default (which was wrong).
But since I did that (January) you are the first one to report of this problem.

Now I changed that and there is a 1.2.7 version of the package.
You can update and see if it will work for your case.
May the Source be with You!

iz3gme

HI!

I've done testing with both old and current arduino ide and I can confirm analogRead now works as expected.

I've also recompiled my original project (FYI https://github.com/iz3gme/k3ng_cw_keyer ) and it looks good.

Thank you very much for your support and quick answer.

Best regards