<?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>FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17782/freertos-with-ble-and-adc-nrf52</link><description>Hi, 
 I&amp;#39;m looking for an example which combines FreeRTOS, BLE and ADC on nrf52 board(10040).
I&amp;#39;m able to have FreeRTOS with BLE, FreeRTOS with ADC but not everything together. 
 I have a conflict in using timer.
FreeRTOS clock is launch via nrf_drv_clock_init</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Nov 2016 15:25:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17782/freertos-with-ble-and-adc-nrf52" /><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68497?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 15:25:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d58ba72e-0e4a-48b2-a7e9-b56b3cd39dff</guid><dc:creator>dchaudet</dc:creator><description>&lt;p&gt;Thanks a lot! It was my problem.
Now, I&amp;#39;ve few tasks with adc in IRQ + BLE!
Have a good day!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68496?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2016 13:36:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9df3a23-2ed5-4389-8cfb-f951eb5f9613</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, I ran your code just now and found the problem.&lt;/p&gt;
&lt;p&gt;The problem is that you are not initializing timer priority so it is set with default priority of 0 which is not allowed by softdevice.&lt;/p&gt;
&lt;p&gt;Initialize your timer3 like below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;

err_code = nrf_drv_timer_init(&amp;amp;m_timer, &amp;amp;timer_cfg, timer_handler);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you then the timer3 intterupt will be with priority 6 which is allowed by softdevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68495?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2016 14:02:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82f774a2-910e-46d3-829c-96ee111e9ff0</guid><dc:creator>dchaudet</dc:creator><description>&lt;p&gt;Hi, did you reproduce the error? Are you able to use FreeRTOS with BLE and ADC?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68494?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 05:50:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bb5cfc6-2236-42df-bee0-06997bcd2393</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Ill try to use your code and try to reproduce this error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68493?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 12:49:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1c94ab8-99ea-4cf8-9371-c397a4b17030</guid><dc:creator>dchaudet</dc:creator><description>&lt;p&gt;With debugger, I&amp;#39;ve no error return on nrf function. It&amp;#39;s at the moment to launch schedule task in FreeRTOS that &lt;code&gt;vPortStartFirstTask( void )&lt;/code&gt; that a signal handler appeared which reset the board and re-init the app. I&amp;#39;m not able to  give more details about what append next. My debbugger doesn&amp;#39;t provide more details.
The BLE API is not called because the code is in a freertos task.&lt;/p&gt;
&lt;p&gt;If i tried to call directly ble_function, an error appeared in the function &lt;code&gt;softdevice_handler_init()&lt;/code&gt; when &lt;code&gt;sd_softdevice_enable()&lt;/code&gt; is called. The error is 4097. I didn&amp;#39;t found any trace of this error. Do you know where it came from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68492?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 12:41:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:020dde20-8a6b-41aa-8f64-3fad69c44919</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi, The code you posted have nothing to do with BLE. Your initialization looks fine (fine in a way that it does not seem to conflict BLE) . Did you see if any of the function returned error here?
When you apply above code , what do you mean by saying BLE does not work. Does it get stuck somewhere? I suggest you to start the debugger and run the program and stop to see where the execution is. I am guessing that BLE API is not called at all in this scenario because i do not see any hardware conflicts in your code snippet above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68491?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 12:28:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:383c5be8-f65f-4d15-903b-3b5339b8efed</guid><dc:creator>dchaudet</dc:creator><description>&lt;p&gt;Thanks for the quick answer.
I agree, I can&amp;#39;t use TIMER0 + RTC0 if I use BLE. My bad! I updated my post. I defined TIMER3.
This is what I did for now :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; - Initialize clock at the beginning of my program (before using any peripheral).
 - Initialize the saadc module with ppi :

static const nrf_drv_timer_t   m_timer = NRF_DRV_TIMER_INSTANCE(3);

ret_code_t err_code;
err_code = nrf_drv_ppi_init();
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_timer_init(&amp;amp;m_timer, NULL, timer_handler);
APP_ERROR_CHECK(err_code);

/* setup m_timer for compare event every 400ms */
uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, 1000);
nrf_drv_timer_extended_compare(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
nrf_drv_timer_enable(&amp;amp;m_timer);

uint32_t timer_compare_event_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0);
uint32_t saadc_sample_event_addr = nrf_drv_saadc_sample_task_get();

/* setup ppi channel so that timer compare event is triggering sample task in SAADC */
err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_ppi_channel_assign(m_ppi_channel, timer_compare_event_addr, saadc_sample_event_addr);
APP_ERROR_CHECK(err_code);

error_code = nrf_drv_saadc_init(NULL, adc_handler);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When I don&amp;#39;t initialize adc, ble works fine. I don&amp;#39;t understand in which part, adc configuration does conflicts. Is there a problem on my way to initialize ppi?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS with BLE and ADC (nrf52)</title><link>https://devzone.nordicsemi.com/thread/68490?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 11:47:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b2b4cb5-8ec7-487e-9690-eac20565afac</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Your application cannot use RTC0 and TIMER0 if you are using BLE. Your application cannot use RTC1 if you are using FreeRTOS. Rest is normal clock rules, that you need to enable them before using any peripheral that needs it. Have you already started making your example and facing some conflicts? if so tell me exactly where and what conflict you are facing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>