-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Subject of the issue
When performing a Analogread() with a pin number that does not have analog support
the Analogread() will not return and loop forever.
Steps to reproduce
loop()
{
Serial.print("test :");
uint16_t tempadc = analogRead(37);
Serial.print("analog pin :");
Serial.println(tempadc);
}
The text 'test :' will be displayed, but 'analog pin :' will not be displayed.
Root cause:
In ap3_analog.h the wrong number of entries is indicated : AP3_ANALOG_PADS where it should be
AP3_ANALOG_CHANNELS. AP3_ANALOG_PADS = 10 where AP3_ANALOG_CHANNELS = 15,
In ap3_analog_structures.c the structures are defined as :
const ap3_analog_channel_map_elem_t ap3_analog_channel_map[AP3_ANALOG_CHANNELS] = {
and
ap3_analog_configure_map_elem_t ap3_analog_configure_map[AP3_ANALOG_CHANNELS] = {
In ap3_analog.h the structures are referenced as :
extern const ap3_analog_channel_map_elem_t ap3_analog_channel_map[AP3_ANALOG_PADS];
and
extern ap3_analog_configure_map_elem_t ap3_analog_configure_map[AP3_ANALOG_PADS];
Solution :
correctly reference the structures in ap3_analog.h as a size AP3_ANALOG_CHANNELS :
extern const ap3_analog_channel_map_elem_t ap3_analog_channel_map[AP3_ANALOG_CHANNELS];
extern ap3_analog_configure_map_elem_t ap3_analog_configure_map[AP3_ANALOG_CHANNELS];