<?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>Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84712/timing-counting-while-using-ble</link><description>Hi, 
 I have combined a couple of examples in order to achieve the following on a custom nRF52810 board: 
 
 Count the number of pulses on a pin (using TIMER1) 
 Read the counter at regular intervals (using TIMER2) and start advertising the counter value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Feb 2022 10:07:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84712/timing-counting-while-using-ble" /><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/354518?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 10:07:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:375efb2c-4c60-4a3d-8b11-de6fd4c3d19b</guid><dc:creator>Erik Hougaard</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thanks for the advice on best practise. I have implemented a separate thread like you suggested, and that has solved the issue - as well as the potential issue of the ISR waiting for the BLE device.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/354078?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 09:57:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86dfadf8-d6de-4dec-b7ba-ed566e9f1803</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hi Erik,&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re able to do advertising in main but not in your interrupt, then I can see a couple possible causes.&lt;/p&gt;
&lt;p&gt;First I would check if the variables you are putting into bt_le_adv_start are defined in your event-handler. A crash like this can happen if your program is trying to access a pointer that is defined with a scope that does not include the function it is called from.&lt;/p&gt;
&lt;p&gt;I would also consider whether it is actually a good idea to call bt_le_adv_start from an interrupt. If this function is waiting for the BLE device to become available then calling it from an interrupt wouldn&amp;#39;t be optimal. If this is the case I would consider making a BLE controller thread that controls the advertising, and use a semaphore to signal to it from your event-handler.&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/354053?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 08:45:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:689764be-068b-496a-900a-c1a63eab7c72</guid><dc:creator>Erik Hougaard</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;I can succesfully start and stop advertising from main(), even with timers and PPI initialized. But as soon as I try starting it from inside the event-handler of the timer, it crashes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So my thought is that the BLE system is properly initialized and that prj.conf is OK, but that I&amp;#39;m doing something else wrong. This is my proj.conf for reference:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_ADC=y
CONFIG_ADC_ASYNC=y

CONFIG_NRFX_GPIOTE=y

CONFIG_SENSOR=y

CONFIG_NRFX_TIMER=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_NRFX_PPI=y

CONFIG_BT=y
CONFIG_BT_BROADCASTER=y
CONFIG_BT_OBSERVER=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_LL_SW_SPLIT=y

CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=n

# Clock Configs
CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=n
CONFIG_NRF_RTC_TIMER=y


##### PRINTING | LOGGING #####
# Print configs

CONFIG_LOG=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=n
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_PRINTK=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n

# Power
CONFIG_SYS_POWER_MANAGEMENT=y
CONFIG_DEVICE_POWER_MANAGEMENT=y
CONFIG_BOARD_ENABLE_DCDC=y


&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/353662?ContentTypeID=1</link><pubDate>Thu, 17 Feb 2022 14:53:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06c8d06d-9fda-4672-9b42-84ef3ce9eddb</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Ah I see.&lt;/p&gt;
&lt;p&gt;With this type of crash I would then suspect that you either haven&amp;#39;t inited ble properly, maybe an interrupt/callback isn&amp;#39;t set up, or possibly something is missing in your prj.conf file.&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/353579?ContentTypeID=1</link><pubDate>Thu, 17 Feb 2022 11:38:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cec68dfc-50d6-4e07-a109-67da1390ca72</guid><dc:creator>Erik Hougaard</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t get any errors or warnings during compile. &amp;quot;ad&amp;quot; is defined in line 45 of the sourcecode, and BT_LE_ADV_NCONN is defined in bluetooth.h&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timing+counting while using BLE</title><link>https://devzone.nordicsemi.com/thread/353116?ContentTypeID=1</link><pubDate>Tue, 15 Feb 2022 13:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1fe4e3e-de0e-4fdd-a569-82e318428e85</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;Looking through your code while looking at your debug prints, it seems like your code crashes when it calls&amp;nbsp;&lt;span&gt;bt_le_adv_start&lt;/span&gt;&lt;span&gt;(BT_LE_ADV_NCONN, ad, &lt;/span&gt;&lt;span&gt;ARRAY_SIZE&lt;/span&gt;&lt;span&gt;(ad),&amp;nbsp;&lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However I can not seem to find &amp;quot;BT_LE_ADV_NCONN&amp;quot; or &amp;quot;ad&amp;quot; defined in your code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Am I mistaken or have you forgotten to define them?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you get warnings about this when compiling?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Einar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>