<?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>Using app_timer callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/838/using-app_timer-callback</link><description>Hello,
I&amp;#39;m trying to do a millisecond counter using app_timer but the callback is never called. I think I have missunderstood how it works.
I&amp;#39;ve tried using the app_timer with or without softdevice, in debug mode and without debug mode, but still the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 18 Oct 2014 06:26:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/838/using-app_timer-callback" /><item><title>RE: Using app_timer callback</title><link>https://devzone.nordicsemi.com/thread/4145?ContentTypeID=1</link><pubDate>Sat, 18 Oct 2014 06:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26b62caf-43c6-4268-95ed-b0a4a393d65a</guid><dc:creator>bg2bkk</dc:creator><description>&lt;p&gt;thank you, it can be applied on my project directly.
I have no other configurations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer callback</title><link>https://devzone.nordicsemi.com/thread/4147?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2013 18:52:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecd694a6-c9bf-451c-8f04-9eb388c57367</guid><dc:creator>Andrei</dc:creator><description>&lt;p&gt;Thanks alot. Programmed it and of course it worked. Then after alot of digging around I found out that I commented RTC1_IRQHandler out of app_timer.c in another test. Lesson learned, don&amp;#39;t modify the sdk base files :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer callback</title><link>https://devzone.nordicsemi.com/thread/4146?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2013 17:36:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1ab71e8-927c-480c-9b89-b1f0713272d9</guid><dc:creator>cocoa</dc:creator><description>&lt;p&gt;Compiled on Mac OS X, gcc-arm-none-eabi-4_7-2013q3, softdevice 5.2.1.&lt;/p&gt;
&lt;p&gt;Attached the compiled program. Two formats, bin and hex file .
Try  and tell me.&lt;/p&gt;
&lt;p&gt;-c&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/build.rar"&gt;build.rar&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer callback</title><link>https://devzone.nordicsemi.com/thread/4144?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2013 16:50:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e706062d-dbd2-4a9b-8255-3acc435a795f</guid><dc:creator>Andrei</dc:creator><description>&lt;p&gt;Hello,
Thanks for the answer, I&amp;#39;ve tried using the example you provided but it still doesn&amp;#39;t work. When used in debug with eclipse it crashes at BLE_STACK_HANDLER_INIT with error 8194 which I checked and seems to be NRF_ERROR_SOFTDEVICE_NOT_ENABLED.
When I tried it without the debugger the LED0 lights up when entering main but still doesn&amp;#39;t blink afterwards (neither does LED1).&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using nrf51822 EK with eclipse, softdevice firmware 5.2.1. Have you used another configuration for the tests or maybe there is a compilation problem?&lt;/p&gt;
&lt;p&gt;Andrei&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer callback</title><link>https://devzone.nordicsemi.com/thread/4143?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2013 14:39:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9651a65-c193-480e-bce6-c60052ada32b</guid><dc:creator>cocoa</dc:creator><description>&lt;p&gt;This code is tested on EK board with soft device,  the callback from timer is called every 500 ms.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

#define LED0	 18
#define LED1	 19
#define BTN0	 16
#define BTN1	 17

#define PRESCALER				0
#define MAX_TIMERS			1
#define OP_QUEUES_SIZE	4
#define USE_SCHEDULER		false

#define TIMER_MS				500
#define TIMER_TICKS			APP_TIMER_TICKS(TIMER_MS, PRESCALER)



// alloc timer object

static app_timer_id_t			 testTimer;



static void powerManager(void)
{
	 uint32_t error_code;
	 error_code = sd_app_event_wait();
	 APP_ERROR_CHECK(error_code);
}

// Timer callback
static void timerDidEnd(void *nil)
{
	 // blink to say Hello!!
	 nrf_gpio_pin_toggle(LED0);
	 nrf_gpio_pin_toggle(LED1);
}


static void bleEventManager(ble_evt_t *stackEvent)
{
	 // stack event received
	 // do nothing
	 switch (stackEvent-&amp;gt;header.evt_id)
	{
		 default:
			break;
	}
}


int main (void)
{
	 uint32_t errorCode;
	 
	 // I&amp;#39;m alive, led0 on
	 GPIO_LED_CONFIG(LED0);
	 GPIO_LED_CONFIG(LED1);
	 nrf_gpio_pin_set(LED0);
	 
	 
	 // stack init
	 BLE_STACK_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,
													BLE_L2CAP_MTU_DEF,
													bleEventManager,
													false);

	 // init timer module
	 APP_TIMER_INIT(PRESCALER, MAX_TIMERS, OP_QUEUES_SIZE, USE_SCHEDULER);
	 
	 // create a timer
	 errorCode = app_timer_create(&amp;amp;testTimer,
																 APP_TIMER_MODE_REPEATED,
																 timerDidEnd);
	 
	 APP_ERROR_CHECK(errorCode);
	 
	 // timer starts,
	 errorCode = app_timer_start(testTimer,
																TIMER_TICKS,
																NULL);
	 APP_ERROR_CHECK(errorCode);
	 
	 
	 for(;;)
		 {
			 powerManager();
	   }
	 
	 
}


&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;-c&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>