SpenceKonde / megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
Other
554 stars 144 forks source link

Possible error around ADCPowerOptions() in Arduino.h #1014

Closed WebGH closed 12 months ago

WebGH commented 12 months ago

Megatinycore version 2.6.8 Arduino IDE Version 1.8.13 uC Attiny1616

I tried to use AdcPowerOptios() but always ran ito the error that none of the options described in the dicumentation worked, they all were declared undefined. So, I looked up the origin and find that the possible options are defined in "Arduino.h" inside the megatinycore sources folder.

BUT: The option "_ADCDISABLE" which should be available for all supported uCs is inside an #ifdef block that is only valid for 2-series parts. In General, all "generic" options seem to be only available for 2-series parts which is NOT what the documentation says. I you use the hex values instead of the defined names, like "0x30" to disable the ADC, it compiles without any issue.

To me it seems the "#endif" of the "_#if MEGATINYCORESERIES < 2" block (starting at line 91 in Arduino.h) seems to be too far down. To my limited understanding this "#endif" should be behind line 183 ? Or the generic options need to be copied to the region between line 91 and 132

SpenceKonde commented 12 months ago

All ADC-related functions should have one definition in the MEGATINYCORE_SERIES < 2 block, and one in the else block. There is no code shared between them, there should be two copies of the ADCPowerOptions function, let's see what is going on

SpenceKonde commented 12 months ago

Ah it was the constant defines only that were missing.

The 4 valid options are now given named defines, and the rest (which don't exist on 0/1) are #defined as badArg("This option is on 2-series tiny and AVR Ex-series only") to try to chase people in the right direction.

Pity this just missed the release by a day.

WebGH commented 12 months ago

Dear Spence,

Thank you very much for the confirmation. I also had issues when using the HEX values direct, instead of named defines. Anyhow, I need some more time to investigate this.

With best regards, Wolfgang

From: Spence Konde (aka Dr. Azzy) @.> Sent: Sunday, October 8, 2023 12:04 PM To: SpenceKonde/megaTinyCore @.> Cc: Wolfgang Ebersbach @.>; Author @.> Subject: Re: [SpenceKonde/megaTinyCore] Possible error around ADCPowerOptions() in Arduino.h (Issue #1014)

Ah it was the constant defines only that were missing.

The 4 valid options are now given named defines, and the rest (which don't exist on 0/1) are #defined as badArg("This option is on 2-series tiny and AVR Ex-series only") to try to chase people in the right direction.

Pity this just missed the release by a day.

— Reply to this email directly, view it on GitHubhttps://github.com/SpenceKonde/megaTinyCore/issues/1014#issuecomment-1751982688, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A32S4Q6E7RTWF7KRJVH52S3X6J3A7AVCNFSM6AAAAAA5VXRX66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRHE4DENRYHA. You are receiving this because you authored the thread.Message ID: @.**@.>>

SpenceKonde commented 12 months ago

Well, the fix to the constant names is in 2.6.10 which will be available in board manager soon. Hex values (as far as I know) work in 2.6.9 and earlier and both should work in 2.6.11, if that's not the case, I don't know that. .