<?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>adc_read() returning -EAGAIN</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108735/adc_read-returning--eagain</link><description>Hi, 
 I am getting started with the 52840DK board and v2.5.0 of the nRF SDK. I have successfully run ADC and Timer examples, but am running into an issue trying to combine the two so that the ADC reads, on P0.02(AIN0) and P0.03(AIN1), occur within the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Feb 2024 12:32:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108735/adc_read-returning--eagain" /><item><title>RE: adc_read() returning -EAGAIN</title><link>https://devzone.nordicsemi.com/thread/471283?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2024 12:32:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68adb1eb-78a1-4552-8283-d4bc59e6d6cd</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do the function call work correctly if called from main() or another non-interrupt context? The issue might be that the timer handler runs in interrupt context, and you are calling a blocking function that depends on other interrupts in lower layers.&lt;/p&gt;
&lt;p&gt;Have you debugged/stepped the application to see where the error code comes from? My guess would be that it comes from k_sem_take() in &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/adc/adc_nrfx_saadc.c#L353"&gt;adc_context_wait_for_completion&lt;/a&gt;() because it timed out waiting for the semaphore from the SAADC interrupt handler.&lt;/p&gt;
&lt;p&gt;Do you need to use a TIMER peripheral with interrupts to trigger the sampling, or could you use a separate Thread to trigger this? If you are only sampling every 5 seconds, this should likely be accurate enough.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>