-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Atmega adc support #6616
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
Atmega adc support #6616
Conversation
223fa00
to
d9cf125
Compare
Add adc capability for atmega based mcu. This currently covers atmega1281, atmega328p and atmega2560. * Prescaler is fixed to /128 (125kHz) * Vref is fixed to 5V
make use of cpu/atmega_common adc capability.
improve arduino sketches support by implementing analogRead function. analogRead(pin) returns the value read from the specified analog pin.
Allow to build with atmega_common adc support.
@mali please close the other PR in case it's obsolete and point to this PR as a last comment. |
How to trigger a new jenkins built without pushing commit ? |
Well the errors are on the mq3 driver, which was merged afaik... maybe a rebase will be enough to include the changes? To retrigger a build you need to login with the github account into Jenkins, then you can start a new building. |
@kYc0o Sorry, haven't found how to force rebuild on Jenkins. I can login, but maybe missing rights ... |
@mali I just rescheduled a build. |
As @kYc0o said, you should be able to restart a build from Jenkins yourself : Click on Details to go to Jenkins, then click "Back to project" and then click "Build now". |
@aabadie thank's. |
@mali, you need to be logged in with your GitHub account (just to be sure ;) ). Otherwise I think this can be because your are not part of the maintainers. |
I don't know how to solve in an elegant way last build failures. |
This allow to build adc based sketches for boards having periph_adc features. Otherwise, only build base arduino features.
I'm testing this PR with arduino-uno without success... Did you try with tests/periph_adc ? |
no, I've done my own tests, will do with tests/periph_adc ... |
I suspect a problem when using multiple ADCs simultaneously, I had only done unit tests ... |
* @{ | ||
*/ | ||
#ifdef CPU_ATMEGA328P | ||
#define ADC_NUMOF (6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the datasheet, there are 8 ADCs (ADC0-7)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
au contraire, Arduino Duemilanove has only 6 analog in pins accessible, though there may be 8 internally. See here, picture and reference table.
ADCSRA |= (1 << ADEN); | ||
|
||
/* Enable ADC with Prescaling = /128 = 125KHz */ | ||
ADCSRA=(1 << ADEN)|(1 << ADPS2)|(1 << ADPS1)|(1 << ADPS0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to include (1 << ADEN) here (as you did above)
ADCSRA=(1 << ADEN)|(1 << ADPS2)|(1 << ADPS1)|(1 << ADPS0); | ||
|
||
/* Ref Voltage is Vcc(5V) */ | ||
ADMUX = (1 << REFS0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for completeness: unset REFS1
@mali, any progress on this one ? It would be great if you could address the comments reported ;) |
@aabadie, yes I plan to rework on it soon. I need to update my debian to new stable and so switch to gcc6, and with this I must be able to compile Riot again ;-) |
I already reworked it. The ADC driver covers now atmega328p, atmega2560 and atmega1281. The driver was tested on each listed Microcontroller. The PR will be come in the next days. Atmega328p with the PDIP package has 6 ADCs (Arduino UNO). But only 5 ADCs can be used, because the pin of ADC5 emulate a software triggered interrupt in RIOT. |
New PR: cpu/atmega_common: add adc driver #7227 |
Closed in favor of PR #7227 |
This PR improve and obsolete PR #6148 by adding adc support to atmega based boards.
For now it covers atmega328p and atmega2560, atmega1281 should be trivial to add.
atmega2560 is only build tested, so it needs real testing by someone having the needed hardware.
Also, it needs PR tests/driver_mq3: fix build upon avr 8 bits MCU #6581 to build properly.