<?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>Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6990/connection-is-disconnected-automatically</link><description>Hi, 
 I&amp;#39;m trying to implement a pulse counter, and send the data to client via BLE. I have debugged the module of the counter without connection separately, it&amp;#39;s working well. But when I&amp;#39;m using USB Dongle for debugging the data, some issue happens:</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 May 2015 04:43:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6990/connection-is-disconnected-automatically" /><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24656?ContentTypeID=1</link><pubDate>Mon, 25 May 2015 04:43:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8035c950-ae08-419c-a72d-8855c745555d</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;Sorry for late response, I was trapped into other issues in these days.&lt;/p&gt;
&lt;p&gt;For this issue, we&amp;#39;re making a new board with a real DA module to generate pulse, and will check if it&amp;#39;s caused by voltage. Will get back to you once the result is coming.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24651?ContentTypeID=1</link><pubDate>Mon, 18 May 2015 11:26:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a70b43-1aab-44bf-998d-f2e82d39c882</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Stanley: I&amp;#39;m not sure I fully understand your configuration. Could you update with the correct configuration of TIMER, PPI, and interrupt handler ?&lt;/p&gt;
&lt;p&gt;You can test if the pulse generator caused the voltage to drop or smth with the hardware by not enabling the interrupt on the input LPCOMP pin to see if the connection is dropped or not. If it won&amp;#39;t then most likely it was the issue with the interrupt handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24655?ContentTypeID=1</link><pubDate>Fri, 15 May 2015 18:17:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec059b23-4f06-4a25-b269-aadae1004d76</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;Is it possible to be caused by the current of input? I don&amp;#39;t have a tool to measure the input current.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24654?ContentTypeID=1</link><pubDate>Fri, 15 May 2015 15:07:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bad18a1-0db5-4cd6-a1f9-2d79e56208b6</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;Sorry for confusing you about the counter. The first line &amp;quot;&lt;code&gt;NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Counter;&lt;/code&gt;   &amp;quot; should be useless. This counter is actually working in TIMER mode, and it&amp;#39;s just used as a TICK counter. When the LPCOMP interrupt happens, the TICK in the TIMER will be read out, and TIMER will be reset for next time usage.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sure the connection is established. I&amp;#39;m using Nordic Master Control Panel on the phone to connect the device, and with Pulse generator turned off, everything works well, I can get the services list from the APP. But once I turned on the generator, the connection was disconnected quickly. Consequently, I can see APP keeps trying to re-connect the device, occasionally can see the refreshed service information in APP.&lt;/p&gt;
&lt;p&gt;I set up the Sniffer on my USB Dongle (PCA00001), with the firmware &amp;quot;ble-sniffer_nRF51822_1.0.1_1111_Sniffer.hex&amp;quot;. The WaveShark version is Wireshark-win64-1.12.5.&lt;/p&gt;
&lt;p&gt;Regards,
Stanley&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24653?ContentTypeID=1</link><pubDate>Fri, 15 May 2015 11:47:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2240d518-2aa6-4d8a-8576-9d97e233c339</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Stanley: I&amp;#39;m seeing you are setting the timer as the counter and then set it as timer later on in same place. Which function you want the timer to operate as ?&lt;/p&gt;
&lt;p&gt;If you want to use it as counter you should not call NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Timer;&lt;/p&gt;
&lt;p&gt;Are you sure the connection is established ? I still don&amp;#39;t really get it on what you implemented on the USB dongle  ? Does it run S120 ? Which firmware did you use ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24652?ContentTypeID=1</link><pubDate>Fri, 15 May 2015 05:53:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2722574a-49d9-4f8b-ae58-1172a2217381</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;I tried to use sniffer to capture the communication between phone and device, but looks like only the advertising data can be captured. Once the connection is setup, no data can be captured. Maybe the way I&amp;#39;m using it is not right.&lt;/p&gt;
&lt;p&gt;For debugging this issue, I found if the counter is not enabled, the issue is gone as well. Below is the code how the counter is initialized:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void counter_timer_init(void)
{
        NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Counter;            // Set the timer in Counter Mode
        NRF_TIMER2-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_16Bit;     //Set counter to 16 bit resolution

        NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Timer;  // Set the timer in Counter Mode
        NRF_TIMER2-&amp;gt;PRESCALER = 6;   //Set prescaler. Higher number gives slower timer. Prescaler = 0 gives 16MHz timer
        NRF_TIMER2-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_16Bit;            //Set counter to 16 bit resolution
        NRF_TIMER2-&amp;gt;CC[0] = MS_TO_TICK(SAMPLING_COUNTER_TIMER_INTERVAL);     //Set value for TIMER compare register 0
}

static void LPCOMP_init(void)
{
        /* Enable interrupt on LPCOMP CROSS event */
        NRF_LPCOMP-&amp;gt;INTENSET = LPCOMP_INTENSET_CROSS_Msk;

        /* Configure LPCOMP - set input source to AVDD*4/8 */
        NRF_LPCOMP-&amp;gt;REFSEL |= (LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling &amp;lt;&amp;lt; LPCOMP_REFSEL_REFSEL_Pos);
        /* Configure LPCOMP - set reference input source to AIN pin 6, i.e. P0.5 */
        NRF_LPCOMP-&amp;gt;PSEL |= (COUNTER_PULSE_INPUT &amp;lt;&amp;lt; LPCOMP_PSEL_PSEL_Pos);

        /* Enable and start the low power comparator */
        NRF_LPCOMP-&amp;gt;ENABLE = LPCOMP_ENABLE_ENABLE_Enabled;

        NVIC_SetPriority(LPCOMP_IRQn, APP_IRQ_PRIORITY_LOW);
        NVIC_EnableIRQ(LPCOMP_IRQn);
}

/** @brief Function for initializing Programmable Peripheral Interconnect (PPI) peripheral.
*   The PPI connects together the LPCOMP event and the TIMER2 COUNT task. 
 */
static void ppi_init(void)
{
        // Configure PPI channel 0 to count up the TIMER counter on every LPCOMP event
        // NRF_PPI-&amp;gt;CH[COUNTER_PPI_CHANNEL].EEP = (uint32_t)&amp;amp;NRF_LPCOMP-&amp;gt;EVENTS_CROSS;
        // NRF_PPI-&amp;gt;CH[COUNTER_PPI_CHANNEL].TEP = (uint32_t)&amp;amp;COUNTER_TIMER-&amp;gt;TASKS_COUNT;

        // Enable PPI channel 0
        NRF_PPI-&amp;gt;CHEN = (COUNTER_PPI_ENABLED &amp;lt;&amp;lt; COUNTER_PPI_POS);
}
 
int counter_init(void)
{
        LPCOMP_init();
        counter_timer_init();
        ppi_init();

        return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Would you please help check what might cause connection disconnected?&lt;/p&gt;
&lt;p&gt;Thanks,
Stanley&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24650?ContentTypeID=1</link><pubDate>Wed, 13 May 2015 16:11:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2948a363-9d7d-4ff5-9607-4c16fe391389</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;The question has been edited to add more information. Will provide more information with sniffer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24649?ContentTypeID=1</link><pubDate>Wed, 13 May 2015 10:55:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eabd8219-c26b-468b-a459-e9f6c4246a93</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Stanley: Could you edit your question and add a some more information on your setup ?&lt;/p&gt;
&lt;p&gt;Which stack you used on your pulse counter ? Which stack you used on the USB dongle ?
Which firmware you used on the USB dongle ?
I assume the log you posted is from the USB dongle ?
Disconnect Reason 0x003E meant BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED, most likely the &lt;strong&gt;connection request&lt;/strong&gt; is not received.
A &lt;a href="https://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF-Sniffer/(language)/eng-GB"&gt;sniffer&lt;/a&gt; trace would really help to debug.&lt;/p&gt;
&lt;p&gt;[EDITED] &amp;quot;connection event&amp;quot;-&amp;gt;&amp;quot;connection request&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection is disconnected automatically</title><link>https://devzone.nordicsemi.com/thread/24648?ContentTypeID=1</link><pubDate>Tue, 12 May 2015 01:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1df97c7e-a4de-4319-b9f0-e0680490b3b5</guid><dc:creator>Stanley</dc:creator><description>&lt;p&gt;More details about this question:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I&amp;#39;m using the SDK7.2&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Without pulse generator connected, I can use USB dongle to communicate with device.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Any else is needed for this question?&lt;/p&gt;
&lt;p&gt;Regards,
Stanly&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>