uint32_t analogReadConversion()
None
NOTE:
In an effort to increase the number of times per second the loop() function is called while using analog read functions, non-blocking equivalent functions have been implemented into the chipKIT-core. Test have shown that these non-blocking analogRead functions are about 2x faster on a PIC32MX (Lenny, FubarinoSD) based chipKIT board and about 4.9x faster on a PIC32MZ (Wi-Fire) based boards.
chipKIT Board | PIC32 | Clock Freq | loop() Frequency Blocking Analog Read | loop() Frequency Non-Blocking Analog Read | Improvement |
---|---|---|---|---|---|
Lenny | MX | 40MHz | 49.14 kHz | 127.39 kHz | 2.59 |
Fubarino | MX | 80MHz | 90.91kHz | 217.39 kHz | 2.39 |
Wi-Fire | MZEFG | 200MHz | 233.10 kHz | 1162.79 kHz | 4.98 |
analogReadConversion() returns the conversion result directly from the ADC1BUF0 register. Prior to calling this fuction you must call analogReadConversionStart() and then periodically check to see if the result is ready testing if analogReadConversionComplete() returns true;
Value | Description |
---|---|
0-1024 | ADC Result (typically 0-1024 or 10bits) |
Note:
The non-blocking analogReadxxx Functions are specific to ChipKit 1.4.0 and later and exceed the Arduino 1.6.x specification.
This example starts an analog read in setup() and then checks to see if the result is ready in the loop() function. If a result is ready the ADC value is assigned to the 'value' variable and a new non-blocking analog read is started. If a result is not ready the code simply continues to execute and does not wait. The ability to continue is why we call this non-blocking.
#define ADC_TEST_PIN 16
void setup() {
analogReadConversionStart(ADC_TEST_PIN);
}
void loop() {
uint32_t value;
if ( analogReadConversionComplete() ) {
value = analogReadConversion();
analogReadConversionStart(ADC_TEST_PIN);
}
}
analogReadConversion(), analogReadConversionStart(), analogReadConversionComplete()