Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Manager
1,364 Views

ADC Control and Status Register on Arduino Breakout Board

I want to change the precision of the analogRead function with my Intel Edison Arduino Breakout board. With an Arduino Uno, I can include "wiring_private.h" and call cbi(ADCSRA, ADPS2), etc. to clear a bit on the ADC Control and Status Register. This changes the precision of analogRead and its execution time. When I try to include "wiring_private.h" in the Arduino IDE with the board set to "Intel Edison", I get a compiler error because it cannot find the library.

What library should I include so that I can use the sbi() and cbi() functions with the Edison Arduino Breakout Board? Does the Arduino Breakout Board's ADC Control and Status Register use the same macro (ADCSRA) as with the Arduino Uno? Where can I find documentation on this?

Also, I read somewhere that the Arduino Breakout Board's ADC is capable of 12-bit precision. Where can I find documentation on that?

-Jason

0 Kudos
3 Replies
Highlighted
Community Manager
7 Views

Hi Jason_Maker,

 

 

There are Arduino libraries that are based on the specific AVR architecture of the MCUs used in the Arduino boards. When you try to use those libraries with Edison, you will get compilation errors because Edison has another architecture. The sci() and cbi() functions are not supported by Edison because they are based on the AVR architecture.

 

 

Unfortunately, there is no documentation about this, but you could use the method analogReadResolution(12) to set 12-bit resolution.

 

 

Regards,

 

-Diego
0 Kudos
Highlighted
Community Manager
7 Views

Can I lower the resolution of analogRead below 10-bit to make analogRead execute faster? Shouldn't I be able to do so by setting and clearing certain ADC register bits?

-Jason

0 Kudos
Highlighted
Community Manager
7 Views

Hi Jason_Maker,

The ADC used by the Arduino expansion board is external. Theoretically, you should be able to access the registers of this IC and configure it through them, however, the way this ADC is accessed and used by the Edison module doesn't allow this, so the only way you can change the resolution is using the method analogReadResolution().

Now, as you can see in the code below, the method limits the parameter to be a value between 1 and 32. I don't know if using, for example, analogReadResolution(4) will set a 4-bit resolution, you could try it of course to see if it has any effect, but I've just used this method to set a 12-bit resolution.

void analogReadResolution(uint32_t res)

 

{

 

if (res >= 1 && res <= 32)<p>  _readResolution = res;

 

}

Regards,

 

-Diego
0 Kudos