<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>low power saadc</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38776/low-power-saadc</link><description>when I start ADC the current will be HIGH .even I UN-Initialization it . 
 what I have done like that below； 
 
 before I started it The current is 0.6ma 
 but when I start it the current becom 7ma . 
 Is there anything else should I do . 
 IS there any</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Sep 2018 06:14:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38776/low-power-saadc" /><item><title>RE: low power saadc</title><link>https://devzone.nordicsemi.com/thread/149928?ContentTypeID=1</link><pubDate>Mon, 24 Sep 2018 06:14:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85d870c3-fb32-4342-b558-7477a5cdfa7c</guid><dc:creator>yangshuanghua</dc:creator><description>&lt;p&gt;HI ，Haakonsh ,&lt;/p&gt;
&lt;p&gt;I have found the cause of the problem.&lt;/p&gt;
&lt;p&gt;During the processing of ADC, I activated the floating point unit.&lt;/p&gt;
&lt;p&gt;The power problem has been solved, thank you all the same .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: low power saadc</title><link>https://devzone.nordicsemi.com/thread/149872?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 15:18:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1588caa3-d15e-4b5f-902a-68195566a251</guid><dc:creator>yangshuanghua</dc:creator><description>&lt;p&gt;sorry pro minite mean per minute . sorry about that I have forgetten that word。&lt;/p&gt;
&lt;p&gt;here is my code about my project .please take a look .&lt;/p&gt;
&lt;p&gt;thank you very much .&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
//SDK_CONFIC.H set

#ifndef SAADC_ENABLED
#define SAADC_ENABLED 1 //改
#endif
#if SAADC_ENABLED
// &amp;lt;o&amp;gt; SAADC_CONFIG_RESOLUTION - Resolution

// &amp;lt;0=&amp;gt; 8 bit 
// &amp;lt;1=&amp;gt; 10 bit 
// &amp;lt;2=&amp;gt; 12 bit 
// &amp;lt;3=&amp;gt; 14 bit

#ifndef SAADC_CONFIG_RESOLUTION
#define SAADC_CONFIG_RESOLUTION 0
#endif

// &amp;lt;o&amp;gt; SAADC_CONFIG_OVERSAMPLE - Sample period

// &amp;lt;0=&amp;gt; Disabled 
// &amp;lt;1=&amp;gt; 2x 
// &amp;lt;2=&amp;gt; 4x 
// &amp;lt;3=&amp;gt; 8x 
// &amp;lt;4=&amp;gt; 16x 
// &amp;lt;5=&amp;gt; 32x 
// &amp;lt;6=&amp;gt; 64x 
// &amp;lt;7=&amp;gt; 128x 
// &amp;lt;8=&amp;gt; 256x

#ifndef SAADC_CONFIG_OVERSAMPLE
#define SAADC_CONFIG_OVERSAMPLE 0
#endif

// &amp;lt;q&amp;gt; SAADC_CONFIG_LP_MODE - Enabling low power mode

#ifndef SAADC_CONFIG_LP_MODE
#define SAADC_CONFIG_LP_MODE 1
#endif

// &amp;lt;o&amp;gt; SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority

// &amp;lt;i&amp;gt; Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7

#ifndef SAADC_CONFIG_IRQ_PRIORITY
#define SAADC_CONFIG_IRQ_PRIORITY 7
#endif

// &amp;lt;e&amp;gt; SAADC_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef SAADC_CONFIG_LOG_ENABLED
#define SAADC_CONFIG_LOG_ENABLED 0
#endif
#if SAADC_CONFIG_LOG_ENABLED
// &amp;lt;o&amp;gt; SAADC_CONFIG_LOG_LEVEL - Default Severity level

// &amp;lt;0=&amp;gt; Off 
// &amp;lt;1=&amp;gt; Error 
// &amp;lt;2=&amp;gt; Warning 
// &amp;lt;3=&amp;gt; Info 
// &amp;lt;4=&amp;gt; Debug

#ifndef SAADC_CONFIG_LOG_LEVEL
#define SAADC_CONFIG_LOG_LEVEL 3
#endif

// &amp;lt;o&amp;gt; SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix.

// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White

#ifndef SAADC_CONFIG_INFO_COLOR
#define SAADC_CONFIG_INFO_COLOR 0
#endif

// &amp;lt;o&amp;gt; SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix.

// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White

#ifndef SAADC_CONFIG_DEBUG_COLOR
#define SAADC_CONFIG_DEBUG_COLOR 0
#endif

#endif //SAADC_CONFIG_LOG_ENABLED
// &amp;lt;/e&amp;gt;

#endif //SAADC_ENABLED
// &amp;lt;/e&amp;gt;

//main fuction 

int main(void)
{

    uint32_t err_code;
    
    ble_stack_init();
    power_first(); //上电就做电源管理
    gap_params_init();
    my_service_Init();
    //services_init();
    advertising_init();
    conn_params_init();
    
    
    // printf(&amp;quot;\r\nUART Start!\r\n&amp;quot;);
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    My_flash_init();
    get_save_and_synchronous_num(); 
    // Enter main loop.
    for (;;)
    {
        if (NRF_LOG_PROCESS() == false)//将保存的LOG都吐出来之后进入休眠
        {
            if(My_Time_Fuction_Enable==1)
            {
                My_Time_Fuction_Process();
                My_Time_Fuction_Enable=0;
            }
            power_manage();
        }
    }
}

//SADDC Initialization
void my_adc_init(void) 
{
    MI_LOG_DEBUG(&amp;quot;my_adc_init\r\n&amp;quot;);
    ret_code_t err_code;
    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);
    
    nrf_saadc_channel_config_t channel_config0 =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(LIGHT_CHECK);
    channel_config0.reference=NRF_SAADC_REFERENCE_VDD4;
    err_code = nrf_drv_saadc_channel_init(LIGHT_CHECK-1, &amp;amp;channel_config0);
    APP_ERROR_CHECK(err_code);
    
    nrf_saadc_channel_config_t channel_config1 =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(BATTRY_CHECK);
    err_code = nrf_drv_saadc_channel_init(BATTRY_CHECK-1, &amp;amp;channel_config1);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool,SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
}



ADC_start(void)  //starts  per minute
{

    err_code=nrf_drv_saadc_sample();//
    APP_ERROR_CHECK(err_code);

}



//saadc callback

void saadc_callback(nrf_drv_saadc_evt_t const * p_event) //ADC完成中断 功能完成，具体参数需要调试
{
    MI_LOG_DEBUG(&amp;quot;saadc_callback\r\n&amp;quot;);
    static uint32_t count=0;
    ret_code_t err_code; 
    count ++ ;
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)//ADC转换完成
    {
        MI_LOG_DEBUG(&amp;quot;ADC has completed %d times\r\n&amp;quot;,count);
        LIGHT_PIN_control(!LIGHT_CONTRL_ACTIVE);
        err_code=nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer,SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
        light_value=(p_event-&amp;gt;data.done.p_buffer[0]);
        MI_LOG_INFO(&amp;quot;the LIGHT_CHECK ADC value is %X\r\n&amp;quot;, light_value);//p_event-&amp;gt;data.done.p_buffer[0]);
        
        MI_LOG_INFO(&amp;quot;the BATTRY_CHECK ADC value is %d \r\n&amp;quot;, p_event-&amp;gt;data.done.p_buffer[1]);
        battry_V=((float )p_event-&amp;gt;data.done.p_buffer[1])/256*0.6*6*133/33;
        battry_level=(uint8_t)((battry_V-BATTRY_ZERO)/(BATTRY_FULL-BATTRY_ZERO)*100);
        if(battry_V&amp;lt;BATTRY_ZERO)
            battry_level=0;
        if(battry_level&amp;gt;100)
            battry_level=100;
        if(battry_level&amp;lt;BATTRY_LOW_WARNING)//电量低
         POWER_LOWER_FLAG=1;
        else 
        POWER_LOWER_FLAG=0;
        MI_LOG_INFO(&amp;quot;the BATTRY value is %d . %d V\r\n&amp;quot;, battry_V,(battry_V-(unsigned char )battry_V)*100);
        
        if( light_value&amp;lt;LIGHT_TOO_HIGH_GATE)
        {
            light_flag=TO_HIGH;
            MI_LOG_INFO(&amp;quot;light is too bright \r\n&amp;quot;);
        }
        else if(light_value&amp;gt;LIGHT_TOO_LOW_GATE)
        {
            light_flag=TO_LOW;
            MI_LOG_INFO(&amp;quot;light is too dark \r\n&amp;quot;);
        }
        else 
            light_flag=NORMAL; 
    }
    if(p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_LIMIT)//超出限制
    {
        MI_LOG_INFO(&amp;quot;ADC NRF_DRV_SAADC_EVT_LIMIT %d \r\n&amp;quot;,count);
    }
    if(p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_CALIBRATEDONE)//校准完成
    {
         MI_LOG_INFO(&amp;quot;ADC NRF_DRV_SAADC_EVT_CALIBRATEDONE %d \r\n&amp;quot;,count);
    }
    nrf_drv_saadc_uninit();
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: low power saadc</title><link>https://devzone.nordicsemi.com/thread/149812?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 11:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bb488d7-fd92-4de1-b69c-ae9dfc502d0e</guid><dc:creator>yangshuanghua</dc:creator><description>&lt;p&gt;I&amp;lsquo;ve tried open dcdc .it downs to 3.75ma&lt;/p&gt;
&lt;p&gt;but what make me&amp;nbsp;puzzled is that&amp;nbsp; &amp;nbsp; &amp;nbsp; :start the SAADC or not ,the current could chang so much .&lt;/p&gt;
&lt;p&gt;start :3.75ma&lt;/p&gt;
&lt;p&gt;no start :0.7ma&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I start SAADC&amp;nbsp; and then it finsh check&amp;nbsp; &amp;nbsp; I &lt;span&gt;UN-Initialized the SAADC but it always be high current .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I give my main fuction below&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    uint32_t err_code;
    ble_stack_init();
	power_first();			
    gap_params_init();
    my_service_Init();
    advertising_init();
    conn_params_init();

//    printf(&amp;quot;\r\nUART Start!\r\n&amp;quot;);
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
	My_flash_init();
	get_save_and_synchronous_num();	
    // Enter main loop.
    for (;;)
    {
		if (NRF_LOG_PROCESS() == false)
		{
			if(My_Time_Fuction_Enable==1)// changes pro min
			{
				My_Time_Fuction_Process();
				My_Time_Fuction_Enable=0;
			}
        power_manage();
		}
    }
}
//most time it wait event until one minite.



void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
...
    nrf_drv_saadc_uninit();	
...
}


//stars pro min
void start_ADC(void)
{
	MI_LOG_DEBUG(&amp;quot;start_ADC\r\n&amp;quot;);
	uint32_t err_code;
	LIGHT_PIN_control(LIGHT_CONTRL_ACTIVE);
	my_adc_init();
	err_code=nrf_drv_saadc_sample();//
	APP_ERROR_CHECK(err_code);
}
// if I Shielded this code   the current would be 0.7ma .
// or it will be 3.75ma


&lt;/pre&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SAADC starts pro minite .and after it finished I &amp;nbsp;UN-Initialized the SAADC.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: low power saadc</title><link>https://devzone.nordicsemi.com/thread/149805?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 10:52:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71375b86-a77d-4de5-9f69-489885b8dfbe</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I&amp;#39;m guessing you&amp;#39;re not using the DCDC regulator and not putting the CPU to sleep after starting the SAADC. Do you mind posting the relevant code to your SAADC usage?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>