Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: ADMUX/ADCSRA not declared in this scope

  1. #1
    Junior Member
    Join Date
    Jun 2015
    Posts
    15

    ADMUX/ADCSRA not declared in this scope

    Hi Folks,

    I'm new to Teensy, I just bought one (3.1). I've been using Arduino up to now. I have Arduino 1.6.3 with Teensyduino installed. I'm just porting over a sketch and I'm encountering compile errors:

    error: 'ADMUX' was not declared in this scope
    error: 'ADCSRA' was not declared in this scope
    error: 'ADCSRB' was not declared in this scope

    Do you know what I need to include to reference these registers?

    Thanks very much

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,186
    Quote Originally Posted by Zaite12 View Post
    Hi Folks,

    I'm new to Teensy, I just bought one (3.1). I've been using Arduino up to now. I have Arduino 1.6.3 with Teensyduino installed. I'm just porting over a sketch and I'm encountering compile errors:

    error: 'ADMUX' was not declared in this scope
    error: 'ADCSRA' was not declared in this scope
    error: 'ADCSRB' was not declared in this scope

    Do you know what I need to include to reference these registers?

    Thanks very much
    There are no such registers, it's a completly different mcu. And it's ARM, not AVR.
    Maybe it's better to describe what are you trying to do, then it's easier for us to help.
    Or, post your sketch ?

  3. #3
    Junior Member
    Join Date
    Jun 2015
    Posts
    15
    Quote Originally Posted by Frank B View Post
    There are no such registers, it's a completly different mcu. And it's ARM, not AVR.
    Maybe it's better to describe what are you trying to do, then it's easier for us to help.
    Or, post your sketch ?
    Hi

    I had a look at the sample ADC code on the website which was referring to these registers but I've just realised it's for Teensy 2.0. I'm hoping to set up the ADC in free running mode and record the voltage on an interrupt.

    I'm also hoping to be able to set up interrupts for pin changes on the digital pins. Any guidance would be much appreciated.

    Thanks very much

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,186
    This is the example for AnalogInput :
    Code:
    /* Analog Input Example, Teensyduino Tutorial #4
       http://www.pjrc.com/teensy/tutorial4.html
    
       After uploading this to your board, use Serial Monitor
       to view the message.  When Serial is selected from the
       Tools > USB Type menu, the correct serial port must be
       selected from the Tools > Serial Port AFTER Teensy is
       running this code.  Teensy only becomes a serial device
       while this code is running!  For non-Serial types,
       the Serial port is emulated, so no port needs to be
       selected.
    
       This example code is in the public domain.
    */
    
    void setup()
    {                
      Serial.begin(38400);
    }
    
    int val;
    
    void loop()                     
    {
      val = analogRead(0);
      Serial.print("analog 0 is: ");
      Serial.println(val);
      delay(250);
    }
    I can't find an easy example for Pinchange at the moment, maybe the others can help....

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,186

  6. #6
    Junior Member
    Join Date
    Jun 2015
    Posts
    15
    Thanks. The digital side looks good as all pins have interrupt capability. On the analog I found (on the mega328) the analogRead() took a little while and caused other parts of the code which timed PWM pulses to jitter, so I switched to free running mode with interrupts. Should I do the same with the Teensy3.1 or does the analogRead() work in a different way? Perhaps it's a lot faster

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,186
    Unless you are generating PWM in software I see no reason for jitter.
    Can you tell more ?

  8. #8
    Junior Member
    Join Date
    Jun 2015
    Posts
    15
    Quote Originally Posted by Frank B View Post
    Unless you are generating PWM in software I see no reason for jitter.
    Can you tell more ?
    I have been using the Arduino Servo library writeMicroseconds() function to control the servos. I'm guessing there is a way to do this on the Teensy3.1? (sorry for such newbie questions, it's just seems hard for a beginner to find info)

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,186
    Why sorry ?
    This is a support forum!

    You may want to try this library:
    http://www.pjrc.com/teensy/td_libs_PulsePosition.html

    There will be no jitter.

  10. #10
    Junior Member
    Join Date
    Jun 2015
    Posts
    15
    This library looks great, and the accuracy delights me! I'll try it out :-)

    Thanks very much for all your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •