<?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>sending data with ble problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11119/sending-data-with-ble-problem</link><description>Hello, I am encountering with problems with sending 20 bytes of data. 
My initial code worked using two timer and I successfully displayed it on an android phone but I wanted to power optimize the code resulting with the changes below but with the change</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Jan 2016 04:25:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11119/sending-data-with-ble-problem" /><item><title>RE: sending data with ble problem</title><link>https://devzone.nordicsemi.com/thread/41649?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2016 04:25:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d2144f5-53af-4748-bb80-04ee7de972ee</guid><dc:creator>monpetit</dc:creator><description>&lt;p&gt;It seems that your tasks are somewhat time consuming. Too heavy-duty task inside an interrupt handler is not recommended, especially with communications stack.
You should restructure your program. For example,&lt;/p&gt;
&lt;p&gt;Before:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void event_handler_a(...)
{
    TASK_A
}

void event_handler_b(...)
{
    TASK_B
}

void event_handler_c(...)
{
    TASK_C
}

int main(void)
{
    ...
    while (1) {
        power_manage();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;typedef struct {
    bool ready_a;
    bool ready_b;
    bool ready_c;
} event_flag_t;

event_flag_t evt_flag = { false, false, false };

void event_handler_a(...)
{
    ESSENTIAL_TASK_A    /* like clearing event and writing adc result... */
    evt_flag.ready_a = true;
}

void event_handler_b(...)
{
    ESSENTIAL_TASK_B
    evt_flag.ready_b = true;
}

void event_handler_c(...)
{
    ESSENTIAL_TASK_C
    evt_flag.ready_c = true;
}

int main(void)
{
    ...
    while (1) {
        if (evt_flag.ready_a) {
            TASK_A
            evt_flag.ready_a = false;
        }

        if (evt_flag.ready_b) {
            TASK_B
            evt_flag.ready_b = false;
        }

        if (evt_flag.ready_c) {
            TASK_C
            evt_flag.ready_c = false;
        }

        power_manage();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>