<?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>RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5520/rbc-mesh-timer-0-usage</link><description>Hi I am using the RBC mesh &amp;quot; github.com/.../nRF51-ble-bcast-mesh&amp;quot; , sd_110_7.1 and sdk_6.2 
 The rbc mesh is using timer0 as well as the softdevice. I removed the app timers from my project so it compiles and works but there is a problem. 
 It craches</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Mar 2015 14:03:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5520/rbc-mesh-timer-0-usage" /><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19287?ContentTypeID=1</link><pubDate>Wed, 18 Mar 2015 14:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d76638c-6cfe-4f13-976c-a1de2bc865e2</guid><dc:creator>Oleh</dc:creator><description>&lt;p&gt;that&amp;#39;s interesting, thanks trond-snekvik!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19290?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2015 11:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c01adbd-e09c-4d84-99b7-15e56d6205bc</guid><dc:creator>victor</dc:creator><description>&lt;p&gt;I am not using the default GAP stuff, I am storing the data in a vector instead to avoid haveing a lot of characteristics. So I can use 255 hadle value pairs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19289?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2015 10:21:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d109fa6c-6321-4fd3-80c4-b51157b575fa</guid><dc:creator>Oleh</dc:creator><description>&lt;p&gt;I see you are using handle_count at 255, the max value is 155.
&amp;quot;The maximum number of handle-value pairs available to the  application. May not be higher than 155 due to BLE namespace requirements&amp;quot; (from: rbc_mesh/rbc_mesh.h)&lt;/p&gt;
&lt;p&gt;could you test it with lower count?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19291?ContentTypeID=1</link><pubDate>Thu, 26 Feb 2015 13:26:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48fa65ed-6699-4785-819b-7da193561bf2</guid><dc:creator>Asbj&amp;#248;rn</dc:creator><description>&lt;p&gt;You can&amp;#39;t use Timer0 outside the time slot. This timer is used by the softdevice and will hardfault if accessed outside the timeslot. &lt;a href="https://www.nordicsemi.com/eng/nordic/download_resource/26762/14/32618036"&gt;I would recommend you to have a look at the shared resources table in the S110 softdevice specification.&lt;/a&gt; As you suggest yourself, try using a timer that&amp;#39;s not controlled by the softdevice and you should at least not have the timer issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19288?ContentTypeID=1</link><pubDate>Thu, 26 Feb 2015 08:10:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee4c6012-5e09-44ef-b372-36bb2a0787f0</guid><dc:creator>victor</dc:creator><description>&lt;p&gt;Thanks for you response I tried your solution but the problem remains.
Stack trace:&lt;/p&gt;
&lt;p&gt;Thread [1] (Suspended: Signal &amp;#39;SIGTRAP&amp;#39; received. Description: Trace/breakpoint trap.)	
13 error_loop() main.c:69 0x000161f4	
12 HardFault_Handler() main.c:113 0x00016284	
11 ()  0xfffffff1	
10 get_available_timer() timer_control.c:80 0x0001bb3a	
9 timer_get_timestamp() timer_control.c:237 0x0001c0b2	
8 timeslot_get_remaining_time() timeslot_handler.c:578 0x0001c9ce	
7 trickle_step_callback() transport_control.c:191 0x0001cbd2	
6 async_event_execute() timeslot_handler.c:229 0x0001c49e	
5 SWI0_IRQHandler() timeslot_handler.c:323 0x0001c5c8	
4 ()  0xfffffff9	
3  0x0001193e	
2  0x0000116a	
1  0x0000116a	&lt;/p&gt;
&lt;p&gt;The line that failed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        NRF_PPI-&amp;gt;CHENCLR = (1 &amp;lt;&amp;lt; (TIMER_PPI_CH_START + i));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;NRF_MPU-&amp;gt;PERR0=0xc300f903 so even if I change to sdoftdevice compatible ppi calls the line 2 lines down will fail:
TIMER0-&amp;gt;EVENTS_COMPARE[i] = 0;&lt;/p&gt;
&lt;p&gt;Can I change timer 0 to some other timer, will this help?&lt;/p&gt;
&lt;p&gt;I think that with your solution the program craches sooner.&lt;/p&gt;
&lt;p&gt;I will attach my rbc mesh code:
&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/rbc_5F00_mesh.zip"&gt;rbc_mesh.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I start the rbc mesh with the following code:
rbc_mesh_init_params_t init_params;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;init_params.access_addr = 0xA541A68F;
init_params.adv_int_ms = 100;
init_params.channel = 38;
init_params.handle_count = 255;
init_params.packet_format = RBC_MESH_PACKET_FORMAT_ADV_COMPATIBLE;
init_params.radio_mode = RBC_MESH_RADIO_MODE_BLE_1MBIT;

error_code = rbc_mesh_init(init_params);
APP_ERROR_CHECK(error_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that I have changed the RBC mesh to suite my needs as I want 255 handles and dont want each handle to be a characteristic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RBC mesh timer 0 usage</title><link>https://devzone.nordicsemi.com/thread/19286?ContentTypeID=1</link><pubDate>Wed, 11 Feb 2015 16:42:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f886833-00b5-416a-96e6-a4e42814ef41</guid><dc:creator>Trond Einar Snekvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is caused by the function being called outside of the RBC mesh timeslot granted by the Softdevice Timeslot API, and is probably the result of a race condition in the framework.&lt;/p&gt;
&lt;p&gt;I am unable to reproduce the crash on my setup, are you able to produce a stack trace of the crash?&lt;/p&gt;
&lt;p&gt;Assuming it happens in the &lt;code&gt;SWI0_IRQHandler()&lt;/code&gt; context, this can (assumably) be fixed by avoiding calling the &lt;code&gt;end_timer_handler()&lt;/code&gt; callback while an async_evt is being processed in SWI0. This could be solved by three minor changes in timeslot_handler.c:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Change both calls to&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;timer_order_cb_sync_exec(g_timeslot_length - TIMESLOT_END_SAFETY_MARGIN_US, end_timer_handler);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;in timeslot_handler.c to&lt;/p&gt;
&lt;p&gt;&lt;code&gt;timer_order_cb(g_timeslot_length - TIMESLOT_END_SAFETY_MARGIN_US, end_timer_handler);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;(notice the removed &lt;code&gt;sync_exec&lt;/code&gt; from the function name). This will put the end_timer_handler in the async_evt queue, instead of interrupting any ongoing async events.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Delete the function &lt;code&gt;end_timer_handler(void)&lt;/code&gt; at &lt;a href="https://github.com/NordicSemiconductor/nRF51-ble-bcast-mesh/blob/master/rbc_mesh/src/timeslot_handler.c#L290"&gt;timeslot_handler.c, L290&lt;/a&gt;, and insert this alternative version instead:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;timeslot_handler.c, L290:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; static bool g_end_timer_triggered = false;
 /**
 * @brief Timeslot end guard timer callback. Attempts to extend the timeslot. 
 */
 static void end_timer_handler(void)
 {
    g_end_timer_triggered = true;

    /* Fake a radio IRQ, making the SD call radio_signal_callback(), letting us end timeslot */
    NVIC_SetPendingIRQ(RADIO_IRQn);
 }`
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Finally, put the following 10 lines right after the large switch-case in &lt;code&gt;radio_signal_callback()&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;_&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (g_end_timer_triggered)
{
    uint32_t length_us = ((g_timeslot_length &amp;gt; 100000)? 100000 : g_timeslot_length);
    radio_request_earliest.params.earliest.length_us = length_us;
    g_ret_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END;
    g_ret_param.params.request.p_next = &amp;amp;radio_request_earliest;
    
    g_next_timeslot_length = length_us;
    
    g_end_timer_triggered = false;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a dirty hotfix, and lacks some proper verification before it should be considered completely safe, but it does not introduce any immediate new errors on my setup. Does this solve your issue (preferrably without introducing new ones)?&lt;/p&gt;
&lt;p&gt;If you could post this issue to the project&amp;#39;s issue tracker on GitHub, I&amp;#39;ll see if I can provide a cleaner fix in the next patch, as it appears to be a bug in the framework.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>