Tiny841 analogRead( PA2) does not work? #609
Replies: 2 comments 2 replies
-
I don't think there should be any problem there, but I wasn't immediately successful confirming that finding the mapping of An constants to ADC channels is in fact correct; the 1634/841/441/828 core is pretty much entirely incomprehensible. That second sub-core is being scrapped and made a normal implementation in 2.0.0 (the next planned release), which will be easier to follow and where analogRead() will be able to interpret pin numbers... [all of that plumbing is completely replaced] Beyond that, I'd need to see wiring to comment further. |
Beta Was this translation helpful? Give feedback.
-
There could very well be a pinmapping issue with the An constants,
everything about how analogRead() interprets pin numbers is fucked up and
inconsistent on ATTinyCore in current released versions, and that shitshow
was a big psrt of the motivation for many changes in 2.0.0 (all of the
variant files were recreated de novo for 2.0.0). I think analogRead(number)
where `number` is the number after ADC on that pin on my pinout charts is
guaranteed to work currently, and guaranteed not to work in 2.0.0 when
behavior will mirror that of my other cores). Anything other than that I
don't claim to know off hand and don't want to look back at; it's
non-trivial and that part of the work for 2.0.0 was long since done; I'm
not confident I could tell you what behavior was expected, sadly, at least
not without lots of study. Like i said, it is/was a shitshow. I started
maintaining ATTinyCore long before I was qualified to do so, and then had
to stay the course to keep from breaking compatibility, which wasn't
avoidable if I wanted it to be consistent or sane. Hence why the next
release involves incrementing the major version....
Anyway
Trace out the board and draw out the schematic, so you can be sure there
isn't some unexpected connection, too.
I'd connect a serial adapter and try to get some debugging output...The
841's have real serial ports so Serial works normally and doesn't suck like
it does for parts with only software serial.
…On Sat, Sep 18, 2021 at 1:51 PM Tigeruno ***@***.***> wrote:
Wiring, I'm using a discarded diyBMSv4 module board, since it already has
most of pads populated. I also just tried LDR on PB2, same result. I tried
blinking my LED number of Value, nothing.
Both are: VCC -> LDR <- (PB2 or PA2) <- 10k -> GND.
[image: diyBMSv4module]
<https://user-images.githubusercontent.com/49213224/133897916-f3bd3d62-d7b4-4f97-a965-434b142b1378.jpg>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#609 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEW3PP3ONGHM2HGGGC6DUCTGTBANCNFSM5EJKSYCQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore <https://github.com/SpenceKonde/ATTinyCore>: Arduino support for
all pre-2016 tinyAVR with >2k flash!
megaTinyCore <https://github.com/SpenceKonde/megaTinyCore>: Arduino support
for all post-2016 tinyAVR parts!
DxCore <https://github.com/SpenceKonde/DxCore>: Arduino support for the AVR
Dx-series parts, the latest and greatest from Microchip!
Contact: ***@***.***
|
Beta Was this translation helpful? Give feedback.
-
I'm new coding this chip, I do have diyBMSv4 code for reference and data sheet.
Trying to use PA2 (RX serial pin) as analog input. I checked voltages at the LDR and they show proper changes with light changes.
void readLDR() // read ldr and choose to open or close door
{ // depends on current time and ldr
uint16_t sumVal = 0;
for (byte i = 0; i < 10; i++)
sumVal += analogRead(A2); // Get current light
val = sumval / 10;
Blink (green, 2);
// Blink (blue, 2);
if (val > 9) // this never happens regardless of brightness of light
Blink(blue, byte (val / 10));
if (DoorFlag && val > ldrMax) // if door is already open don't try to open again
Beta Was this translation helpful? Give feedback.
All reactions