Teensyduino 1.51 errors on compile, 1.48 does not; ADC class implicated

ryreinc

Member
Hello,

I just upgraded Arduino from 1.8.10 to 1.8.12, and correspondingly upgraded Teensyduino from 1.48 to 1.51. However now my Teensy 3.5 project will not compile, giving the errors below. If I go back to 1.8.10 and 1.48 respectively, without changing the project it now compiles successfully again.

Code:
error: 'class ADC' has no member named 'setResolution'
error: 'class ADC' has no member named 'setConversionSpeed'
error: 'class ADC' has no member named 'setSamplingSpeed'
error: 'class ADC' has no member named 'setAveraging'
error: 'class ADC' has no member named 'getMaxValue'

The associated code has been working for quite some time now.

I am running the installations with basically default options. I am unchecking the box for an Arduino desktop icon, and I am electing to install all libraries for the Teensyduino install.
 
I'm experiencing the same issue. error: 'class ADC' has no member named 'setAveraging'
Arduino: 1.8.12
Teensyduino: 1.51

I haven't downgraded yet as I have another computer running an older version.

Worth noting this error was received on a fresh install, not an upgrade. Finally got a new computer!
 
Warning, the owner of the ADC class changed the interface.

In particular he removed a bunch of the members from the main ADC class, and moved them to the modules. He did that for most of the members which have a ADC_NUM parameter at the end of the API...

So the code needs to change to be be like the updated examples:
Code:
  ///// ADC0 ////
    adc->adc0->setAveraging(16); // set number of averages
    adc->adc0->setResolution(16); // set bits of resolution
    adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_LOW_SPEED); // change the conversion speed
    adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED); // change the sampling speed

    ////// ADC1 /////
    #ifdef ADC_DUAL_ADCS
    adc->adc1->setAveraging(16); // set number of averages
    adc->adc1->setResolution(16); // set bits of resolution
    adc->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED); // change the conversion speed
    adc->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED); // change the sampling speed
    #endif
 
Very interesting, thank you KurtE. I didn't realize minor version changes could break reverse compatibility! But I definitely see how that could be unavoidable too. I haven't tried this but clampron's success bodes well; I'll report if I have different results.
 
@ Kurt: Thank you!! That worked :)

I have the same problem with a Teensy 3.6 using Mozzi.... but i don't exactly know, how and where to implement the fix.
Cloud some someone explain me, how in which file (maybe in which lihe) i have to paste this code.

Thank u varey much
 
I have the same problem with a Teensy 3.6 using Mozzi.... but i don't exactly know, how and where to implement the fix.
Cloud some someone explain me, how in which file (maybe in which lihe) i have to paste this code.

Thank u varey much

Not very easily as don't see your code nor your error messages to know what/where to fix.

But for example if you have a line like:
Code:
adc->setAveraging(16)
or
Code:
adc->setAveraging(16)

It needs to be changed to something like:
Code:
adc->adc0->setAveraging(16)

And if it was like:
Code:
adc->setAveraging(16,1)
needs to go to:
Code:
adc->adc1->setAveraging(16)
...

Why these changes? The owner of the library thought it made the code look cleaner.
(Note I am not the owner)
 
Not very easily as don't see your code nor your error messages to know what/where to fix.

Thank you very much for your answer:

This is my code:
Code:
#include <MozziGuts.h>        
#define CONTROL_RATE 64

void setup() 
{
  startMozzi(CONTROL_RATE);
}

void updateControl() 
{
  
}

int updateAudio() 
{
  return 0;
}

void loop() 
{
  audioHook(); 
}

This are the errors:
Code:
D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\MozziGuts.cpp:45:2: warning: #warning "Mozzi has been tested with a cpu clock speed of 16MHz on Arduino and 48MHz on Teensy 3!  Results may vary with other speeds." [-Wcpp]

 #warning                                                                       \

  ^

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\MozziGuts.cpp: In function 'void startAudioStandard()':

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\MozziGuts.cpp:503:8: error: 'class ADC' has no member named 'setAveraging'

   adc->setAveraging(0);

        ^

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\MozziGuts.cpp:504:8: error: 'class ADC' has no member named 'setConversionSpeed'

   adc->setConversionSpeed(

        ^

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\mozzi_analog.cpp: In function 'void setupMozziADC(int8_t)':

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\mozzi_analog.cpp:74:7: error: 'class ADC' has no member named 'enableInterrupts'

  adc->enableInterrupts(ADC_0);

       ^

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\mozzi_analog.cpp: At global scope:

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\mozzi_analog.cpp:140:13: warning: 'void adcSetChannel(uint8_t)' defined but not used [-Wunused-function]

 static void adcSetChannel(uint8_t channel) {

             ^

D:\LIBRARY\DOCUMENTS\Arduino\libraries\Mozzi-master\mozzi_rand.cpp:148:2: warning: #warning Automatic random seeding not implemented on this platform [-Wcpp]

 #warning Automatic random seeding not implemented on this platform

  ^

Error compiling for board Teensy 3.6.

jusr recently imported the mozzi-master.zip library from github


does this meen, i have to alter code in the mozzi library itself?
 
Thank you very much for your answer:


jusr recently imported the mozzi-master.zip library from github


does this meen, i have to alter code in the mozzi library itself?

Probably. Alternatively you might raise an issue with the owner of ADC library:
https://github.com/pedvide/ADC

And suggest that we add back in some of the methods as to retain more comparability with previous releases.
 
The version of the library has broken some of my code. Most of the issue has been traced to the interface changes mentioned in this thread.
However, this doesn't solve all the recent problems. I'm presently seeing issues getting measurements to complete. Questions:

This the line I'm using to start conversions. It never calls the interrupt and if I manually read the output after conversions should have been complete the result is always zero.
ADC_ERROR =adc->startSynchronizedContinuous(ANA_PIN0,ANA_PIN1);

I tried this line for a single channel, and it did the same. Interrupt is never called.
//ADC_ERROR =adc->adc0->startContinuous(ANA_PIN0);

I tried this and the output was -70000.
adc0=adc->adc0->analogRead(ANA_PIN0);
Serial.println(adc0);

Obviously something else changed, but I can't tell what...all the calls go through without error, but nothing happens.
Is this the correct format to implement the enable interrupts c
 
@kdharbert, Might help if included some additional information, like which teensy? Also simple example sketch which is not working now...

I assume in your above your code has this uncommented: //ADC_ERROR =adc->adc0->startContinuous(ANA_PIN0);

Note: a few of us helped to get some of the code to run on T4, but I not an expert in all of the details.

So for example I am unsure what you mean by interrupt never being called? Which interrupt.

The example sketch analogContinuousRead I do see they set an interrupt, by the call:
adc->adc0->enableInterrupts(adc0_isr);

Where the example sketch does nothing with the results:
Code:
void adc0_isr(void) {
    adc->adc0->analogReadContinuous();
    digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN)); // Toggle the led
}

But without a sketch to look at and an idea of which Teensy, hard to say what is going on. For example is ANA_PIN0 a valid pin on your processor?
 
I found the problem. If you goober the pins wrt what pin matches what ADC, the call still returns 0 and hides your error.
 
Thanks for this thread. I'm at the house looking for things to due during the pandemic, so I thought I'd resurrect some code I wrote a couple of years ago and try porting from the teensy 3.6 to the teensy 4. Tried compiling some ADC code and it failed. The ADC library also kacked on the following code:
if (adc->adc0->fail_flag) {
Serial.print("ADC error: ");
Serial.println(adc->adc0->fail_flag, HEX);
}

Looks like I found something to keep me busy!
 
Aha! This is what I'm looking for.
I am surprised the Mozzi library does not have some conditional defines for this stuff.
 
Hello,

Where does this stand? Using the latest Teensyduino with the LC and Mozzi is producing compilation errors.
A contributor narrowed it down to a simple test w/o Mozzi.
If you are using the LC, this sketch will not compile:

#include <ADC.h> void setup() {} void loop() {}

Thanks,

Ben
 
Looks like there has been an Open PR against the library since last December: https://github.com/pedvide/ADC/pull/81
Which does fix the compile error.

Does not look like @pedvide (the owner of the library) is very active with it. I believe I may have write access to it, for when a few of us were adding T4 support to the library.
So I will probably try to merge it. BUT I do not own this library, nor want to!
 
I went ahead and merged it. So both mine and Pedvide master branches have this fix in it.

Hopefully will be picked up for next TD release

Warning: again, I am not the owner of this library, but have access, but will not do this on a normal basis, but this seamed simple enough.
 
Back
Top