what is minimum clock at which adc can operate in nrf51??. can anyone tell me?? how to change adc clock in nrf51??. i am using sdk11
what is minimum clock at which adc can operate in nrf51??. can anyone tell me?? how to change adc clock in nrf51??. i am using sdk11
You don't have any measurements?
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. * * The information contained herein is property of Nordic Semiconductor ASA. * Terms and conditions of usage are described in detail in NORDIC * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. * * Licensees are granted free, non-transferable use of the information. NO * WARRANTY of ANY KIND is provided. This heading must NOT be removed from * the file. * */
/** @file
* @defgroup nrf_adc_example main.c
* @{
* @ingroup nrf_adc_example
* @brief ADC Example Application main file.
*
* This file contains the source code for a sample application using ADC.
*
* @image html example_board_setup_a.jpg "Use board setup A for this example."
*/
#include "nrf.h"
#ifdef NRF51
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "nrf_adc.h"
#include "boards.h"
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
volatile int32_t adc_sample;
#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 1 /**< UART RX buffer size. */
#ifndef NRF_APP_PRIORITY_HIGH
#define NRF_APP_PRIORITY_HIGH 1
#endif
/**
* @brief UART events handler.
*/
void uart_events_handler(app_uart_evt_t * p_event)
{
switch (p_event->evt_type)
{
case APP_UART_COMMUNICATION_ERROR: APP_ERROR_HANDLER(p_event->data.error_communication);
break;
case APP_UART_FIFO_ERROR: APP_ERROR_HANDLER(p_event->data.error_code);
break;
case APP_UART_TX_EMPTY:
break;
default: break;
}
}
/**
* @brief ADC interrupt handler.
*/
void ADC_IRQHandler(void)
{
nrf_adc_conversion_event_clean();
adc_sample = nrf_adc_result_get();
}
/**
* @brief UART initialization.
*/
void uart_config(void)
{
uint32_t err_code;
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_DISABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud38400
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_events_handler,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
}
/**
* @brief ADC initialization.
*/
void adc_config(void)
{
const nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT;
// Initialize and configure ADC
nrf_adc_configure( (nrf_adc_config_t *)&nrf_adc_config);
nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_2);
nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);
NVIC_EnableIRQ(ADC_IRQn);
}
/**
* @brief Function for main application entry.
*/
int main(void)
{
adc_config();
//uart_config();
printf("\n\rADC HAL simple example\r\n");
printf("Current sample value:\r\n");
while (true)
{
// trigger next ADC conversion
nrf_adc_start();
// enter into sleep mode
__SEV();
__WFE();
__WFE();
nrf_delay_ms(1000);
float value = (float)((adc_sample*3.6)/1024);
int adc_sample1;
uint8_t b_percent;
adc_sample1 =(int)adc_sample;
if(adc_sample1 > 835)
{
b_percent = 0x64;
}
else if(adc_sample1 < 480)
{
b_percent =0x00;
}
else
b_percent = ((adc_sample1-480)*100/355);
// printf("%d\r\n", (int)adc_sample); // out ADC result
// printf("%f\r\n", (float)value); // out ADC result
// printf("%d\r\n", adc_sample1); // out ADC result
// printf("%x\r\n", b_percent);
}
}
#endif /* NRF51 */
/** @} */
i use this code and then measure current and i am getting 11 mA
During the delay (nrf_delay_ms(..)
) the CPU will be running and the current draw will large (several milliamps).
Hi I removed delay part and i get 4 ma current