<?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>nRF52832 SAADC - modify values</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57808/nrf52832-saadc---modify-values</link><description>Hi all, I&amp;#39;m developing software for nRF52832. 
 It includes function of SAADC. 
 My saadc_callback function is below. 
 
 It fills buffer at that time. 
 However, I&amp;#39;m wondering if I can put modified numbers in the buffer, not original A-D converted one</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Feb 2020 11:57:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57808/nrf52832-saadc---modify-values" /><item><title>RE: nRF52832 SAADC - modify values</title><link>https://devzone.nordicsemi.com/thread/234885?ContentTypeID=1</link><pubDate>Tue, 18 Feb 2020 11:57:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e19d6f61-2eae-4cd3-8da0-14d919b6f2ec</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The data is stored in the buffer that p_buffer points to. You could modify the buffer but it will be overwritten after a new sample. I would instead recommend copying the buffer in the interrupt handler and save the current state in a variable. Then process the copied buffer in main context based on the saved state. You should avoid doing any time consuming tasks in the interrupt context as it could interfere with time critical operations such as the Softdevice.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        
        /*1. Set temp buffer to p_buffer
          2. Save state
          3. Set flag to indicate that buffer should be processed in main context*/
        
        memcpy(temp_buf, p_buffer, sizeof(p_buffer));
        state_var = state;
        flag = 1;
        
        
        ret_code_t err_code;
        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
        
    }
}




int main(void)
flag = 0;

{
    
    while(true)
    {
     if(flag == 1)
     {
        //add number to buffer based on state
        flag = 0;
     }
        
    }
    
}
    
    

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>