Skip to content

Commit 871447f

Browse files
committed
Merge branch 'adc_default' into hyperfirmata
2 parents acd6b31 + c6a6d04 commit 871447f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ For 64-bit Linux users, ```libc6:i386```, ```libstdc++6:i386```, ```libncurses5
7474

7575
__NOTE__: To roll back to the original driver go to: Device Manager -> Right click on device -> Check box for "Delete the driver software for this device" and click Uninstall
7676

77+
### Selecting a SoftDevice
78+
SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded.
79+
The SD consumes ~5k of Ram + some extra based on actual BLE configuration.
80+
* SoftDevice S110 v8.0.0 supports [Revision](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf51%2Fdita%2Fnrf51%2Fcompatibility_matrix%2FnRF51822_ic_revision_overview.html&cp=3_0_1) 2 and 3 of nRF51 in peripheral role. It is 96k in size.
81+
* SoftDevice S130 v2.0.1 supports Revision 3 of nRF51 in peripheral and central role. It is 108k in size.
82+
* SoftDevice S132 v2.0.1 supports nRF52 in peripheral and central role. It is 112k in size.
7783

7884
### Flashing a SoftDevice
7985

@@ -117,7 +123,7 @@ This Arduino Core does **not** contain any Arduino style API's for BLE functiona
117123

118124
If the selected board has an external 32 kHz crystal connected, it will be used as the source for the low frequency clock. Otherwise the internal 32 kHz RC oscillator will be used. The low frequency clock is used by the `delay(ms)` and `millis()` Arduino API's.
119125

120-
The Generic nRF51 and nRF52 board options have an additional menu item under `Tools -> Low Frequency Clock` that allows you to select the low frequency clock source.
126+
The Generic nRF51 and nRF52 board options have an additional menu item under `Tools -> Low Frequency Clock` that allows you to select the low frequency clock source. However, Nordic does not recommend the Synthesized clock, which also has a significant power impact.
121127

122128
## Credits
123129

cores/nRF5/wiring_analog_nRF51.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static struct PWMContext pwmContext[PWM_COUNT] = {
4747

4848
static int timerEnabled = 0;
4949

50-
static uint32_t adcReference = ADC_CONFIG_REFSEL_VBG;
50+
static uint32_t adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
5151
static uint32_t adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;
5252

5353
static uint32_t readResolution = 10;
@@ -89,10 +89,8 @@ static inline uint32_t mapResolution( uint32_t value, uint32_t from, uint32_t to
8989
*/
9090
void analogReference( eAnalogReference ulMode )
9191
{
92-
switch ( ulMode ) {
93-
case AR_DEFAULT:
92+
switch ( ulMode ) {
9493
case AR_VBG:
95-
default:
9694
// 1.2 Reference, 1/3 prescaler = 0 V - 3.6 V range
9795
// Minimum VDD for full range in safe operation = 3.3V
9896
adcReference = ADC_CONFIG_REFSEL_VBG;
@@ -105,12 +103,6 @@ void analogReference( eAnalogReference ulMode )
105103
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling;
106104
break;
107105

108-
case AR_SUPPLY_ONE_THIRD:
109-
// 1/3 VDD Reference, 1/3 prescaler = 0 V - VDD range
110-
adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
111-
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;
112-
break;
113-
114106
case AR_EXT0:
115107
// ARF0 reference, 2/3 prescaler = 0 V - 1.5 ARF0
116108
adcReference = ADC_CONFIG_REFSEL_External | (ADC_CONFIG_EXTREFSEL_AnalogReference0 << ADC_CONFIG_EXTREFSEL_Pos);
@@ -122,6 +114,14 @@ void analogReference( eAnalogReference ulMode )
122114
adcReference = (ADC_CONFIG_REFSEL_External | ADC_CONFIG_EXTREFSEL_AnalogReference1 << ADC_CONFIG_EXTREFSEL_Pos);
123115
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling;
124116
break;
117+
118+
case AR_SUPPLY_ONE_THIRD:
119+
case AR_DEFAULT:
120+
default:
121+
// 1/3 VDD Reference, 1/3 prescaler = 0 V - VDD range
122+
adcReference = ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling;
123+
adcPrescaling = ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling;
124+
break;
125125
}
126126
}
127127

0 commit comments

Comments
 (0)