Skip to content

Is it possible to change ADC speed to speed up analogRead #2454

@ataytanzer

Description

@ataytanzer

Basic Infos

Hardware

Hardware: Wemos D1 mini (ESP8266)
Core Version: 2.1.0

Description

Problem description

Settings in IDE

Module: Wemos D1 mini
Flash Size: 4MB
CPU Frequency: 160Mhz
Flash Mode:
Flash Frequency:
Upload Using: SERIAL
Reset Method:

Sketch

# ifndef cbi
# define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
# endif
# ifndef sbi
# define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
# endif

// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;

Debug Messages

 sbi(ADCSRA,ADPS2) ;

     ^

C:\Users\tanze\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/pgmspace.h:31:23: note: in definition of macro '_SFR_BYTE'

 #define _SFR_BYTE(n) (n)

                       ^

C:\Users\tanze\Desktop\Spo2_650usec_wemos\Spo2_650usec_wemos.ino:43:1: note: in expansion of macro 'sbi'

 sbi(ADCSRA,ADPS2) ;

 ^

In file included from C:\Users\tanze\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Servo\src/Servo.h:52:0,

                 from C:\Users\tanze\Desktop\Spo2_650usec_wemos\Spo2_650usec_wemos.ino:2:

Spo2_650usec_wemos:43: error: 'ADPS2' was not declared in this scope

 sbi(ADCSRA,ADPS2) ;

            ^

C:\Users\tanze\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:184:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\tanze\Desktop\Spo2_650usec_wemos\Spo2_650usec_wemos.ino:43:1: note: in expansion of macro 'sbi'

 sbi(ADCSRA,ADPS2) ;

 ^

Spo2_650usec_wemos:44: error: 'ADPS1' was not declared in this scope

 cbi(ADCSRA,ADPS1) ;

            ^

C:\Users\tanze\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:184:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\tanze\Desktop\Spo2_650usec_wemos\Spo2_650usec_wemos.ino:44:1: note: in expansion of macro 'cbi'

 cbi(ADCSRA,ADPS1) ;

 ^

Spo2_650usec_wemos:45: error: 'ADPS0' was not declared in this scope

 cbi(ADCSRA,ADPS0) ;

            ^

C:\Users\tanze\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:184:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\tanze\Desktop\Spo2_650usec_wemos\Spo2_650usec_wemos.ino:45:1: note: in expansion of macro 'cbi'

 cbi(ADCSRA,ADPS0) ;

Hello,
I am trying to use faster analogRead function. So I want to change prescaler of the ADC in ESP8266 actually in Wemos. I need to change prescaler of ADC to 16 because in my application analogRead speed is very important(like 14-17 microseconds max).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions