Skip to content

Conversation

mali
Copy link
Contributor

@mali mali commented Feb 15, 2017

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.

@mali mali force-pushed the atmega_adc_support branch from 223fa00 to d9cf125 Compare February 15, 2017 20:43
mali added 4 commits February 15, 2017 21:56
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.
@PeterKietzmann PeterKietzmann added Platform: AVR Platform: This PR/issue effects AVR-based platforms Area: drivers Area: Device drivers Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Feb 16, 2017
@PeterKietzmann PeterKietzmann added this to the Release 2017.04 milestone Feb 16, 2017
@PeterKietzmann
Copy link
Member

@mali please close the other PR in case it's obsolete and point to this PR as a last comment.

@mali
Copy link
Contributor Author

mali commented Feb 16, 2017

How to trigger a new jenkins built without pushing commit ?

@mali mali mentioned this pull request Feb 16, 2017
@kYc0o
Copy link
Contributor

kYc0o commented Feb 16, 2017

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.

@mali
Copy link
Contributor Author

mali commented Feb 17, 2017

@kYc0o Sorry, haven't found how to force rebuild on Jenkins. I can login, but maybe missing rights ...

@aabadie
Copy link
Contributor

aabadie commented Feb 17, 2017

@mali I just rescheduled a build.

@aabadie
Copy link
Contributor

aabadie commented Feb 17, 2017

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".

@mali
Copy link
Contributor Author

mali commented Feb 17, 2017

@aabadie thank's.
I can confirm I don't have this "Build now" option.

@aabadie
Copy link
Contributor

aabadie commented Feb 17, 2017

@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.

@mali
Copy link
Contributor Author

mali commented Feb 22, 2017

I don't know how to solve in an elegant way last build failures.
I've added arduino adc API implementation into /sys/arduino but now, boards that have arduino feature enabled but no adc support failed to build.
I've tried adding FEATURES_REQUIRED = perip_adc in sys/arduino Makefile, also tried to mark arduino adc API with #ifdef FEATURE_PERIPH_ADC but without success.
remove arduino feature for these boards ? I don't like the idea ...
any hints ?
[Edit] I have used #ifdef ADC_NUMOF to do conditional compilation

This allow to build adc based sketches for boards having periph_adc features.
Otherwise, only build base arduino features.
@kYc0o
Copy link
Contributor

kYc0o commented Mar 3, 2017

I'm testing this PR with arduino-uno without success... Did you try with tests/periph_adc ?

@mali
Copy link
Contributor Author

mali commented Mar 3, 2017

no, I've done my own tests, will do with tests/periph_adc ...

@mali
Copy link
Contributor Author

mali commented Mar 6, 2017

I suspect a problem when using multiple ADCs simultaneously, I had only done unit tests ...

* @{
*/
#ifdef CPU_ATMEGA328P
#define ADC_NUMOF (6)
Copy link
Member

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)

Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for completeness: unset REFS1

@aabadie
Copy link
Contributor

aabadie commented Jun 20, 2017

@mali, any progress on this one ? It would be great if you could address the comments reported ;)

@mali
Copy link
Contributor Author

mali commented Jun 20, 2017

@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 ;-)

@ghost
Copy link

ghost commented Jun 21, 2017

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.

@ghost
Copy link

ghost commented Jun 22, 2017

New PR: cpu/atmega_common: add adc driver #7227

@ghost ghost mentioned this pull request Jun 22, 2017
@mali
Copy link
Contributor Author

mali commented Jun 28, 2017

Closed in favor of PR #7227

@mali mali closed this Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants