From: Nathael Pajani Date: Tue, 21 Oct 2014 22:21:08 +0000 (+0200) Subject: Fix problem with ADC at conversion rates above a few hertz (3 or 4Hz) as updated... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=461a704a0f9ec4dde3fea3bb4124d57fd157ad80;p=soft%2Flpc122x%2Fcore Fix problem with ADC at conversion rates above a few hertz (3 or 4Hz) as updated in user manual rev2.1 See Section 19.2 of UM10441 revision 2.1 or newer for more information. --- diff --git a/core/system.c b/core/system.c index 5f28188..a11e6ea 100644 --- a/core/system.c +++ b/core/system.c @@ -100,6 +100,9 @@ void system_brown_out_detection_config(uint32_t level) sys_ctrl->powerdown_run_cfg |= LPC_POWER_DOWN_BOD; lpc_private.brown_out_detection_enabled = 0; } else { + /* Power on Brown-Out Detection. + * (Needed for ADC, See Section 19.2 of UM10441 revision 2.1 or newer for more information) */ + sys_ctrl->powerdown_run_cfg &= ~(LPC_POWER_DOWN_BOD); lpc_private.brown_out_detection_enabled = 1; /* Configure Brown-Out Detection */ /* FIXME */ diff --git a/drivers/adc.c b/drivers/adc.c index 8d4dfc9..fce8721 100644 --- a/drivers/adc.c +++ b/drivers/adc.c @@ -205,6 +205,11 @@ void adc_on(void) /* Disable ADC Interrupt */ NVIC_DisableIRQ(ADC_IRQ); + + /* Brown-Out detection must be powered to operate the ADC. + * See Section 19.2 of UM10441 revision 2.1 or newer for more information */ + sys_ctrl->powerdown_run_cfg &= ~LPC_POWER_DOWN_BOD; + /* Power-up ADC */ sys_ctrl->powerdown_run_cfg &= ~LPC_POWER_DOWN_ADC; /* Provide clock to ADC */ diff --git a/include/core/system.h b/include/core/system.h index 0ce6faf..8686bd6 100644 --- a/include/core/system.h +++ b/include/core/system.h @@ -71,7 +71,10 @@ void enter_deep_sleep(void); /* Power on or off a subsystem */ void subsystem_power(uint32_t power_bit, uint32_t on_off); -/* Configure the brown-out detection */ +/* Configure the brown-out detection. + * Note: Brown-Out detection must be powered to operate the ADC (See Section 19.2 + * of UM10441 revision 2.1 or newer for more information) + */ void system_brown_out_detection_config(uint32_t level); /***************************************************************************** */