<?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>Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77279/cutting-power-to-nrf51-after-receiving-spi-bytes-and-advertising-them-using-ble</link><description>Hi all, 
 I&amp;#39;m working on a limited power budget system. MSP430 is the master that is supplying power to nrf51882 (slave). Every 2s MSP430 derives a pin high to drive the nrf51&amp;#39;s VCC high and send multiple bytes. nrf51 after receiving the bytes through</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Jul 2021 16:09:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77279/cutting-power-to-nrf51-after-receiving-spi-bytes-and-advertising-them-using-ble" /><item><title>RE: Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/thread/320095?ContentTypeID=1</link><pubDate>Wed, 14 Jul 2021 16:09:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc9cad00-1e1e-446e-892b-889b0ecbf3b2</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;br /&gt;&lt;br /&gt;Thank you for your patience with this. The summer holidays have begun here in Norway, and DevZone is therefore operating with reduced staff for the time being. Sorry for any inconvenience this might cause.&lt;/p&gt;
[quote user="aalsubhi"]Thank for you informative and fast response.[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="aalsubhi"]It works fine by setting the advertisement interval to 100ms and make the MSP430 (master) wait more than 100ms (about 300ms-500ms) before cutting the power on nrf51 (slave).[/quote]
&lt;p&gt;Do I understand this correctly that you went for a merge of the two approaches - having the nRF51 enter sleep mode on its own following completed advertising, and then cutting its power afterwards? If so, could you elaborate why you still opt to cut its power? I am interpreting &amp;#39;cutting its power&amp;#39; literally, i.e that you toggle a transistor on its power supply lines, or similar. Do I have this correctly?&lt;br /&gt;I would think that you could achieve lower power consumption by doing either of the things, like suggested in my previous comment.&lt;br /&gt;Did you try the two approaches separately, to compare their power consumption?&lt;/p&gt;
[quote user="aalsubhi"]I solved this problem. I used SPI mode 0&amp;nbsp;(CPOL = 0, CPHA = 0) on nrf51 and&amp;nbsp;(CPOL=0 CPHA=1) on msp430. Also, I have to wait at least 3ms after turning the nrf51&amp;#39;s power on before sending any data through spi.[/quote]
&lt;p&gt;I am glad to hear that you were able to resolve this new issue! These 3 ms of wakeup cycles is what I was referring to as potentially negatable through keeping the device in SYSTEM ON sleep between advertisements.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/thread/319690?ContentTypeID=1</link><pubDate>Mon, 12 Jul 2021 23:13:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e163893-2934-4a88-9613-ffc314ea3987</guid><dc:creator>aalsubhi</dc:creator><description>&lt;p&gt;I solved this problem. I used SPI mode 0&amp;nbsp;(CPOL = 0, CPHA = 0) on nrf51 and&amp;nbsp;(CPOL=0 CPHA=1) on msp430. Also, I have to wait at least 3ms after turning the nrf51&amp;#39;s power on before sending any data through spi.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/thread/319493?ContentTypeID=1</link><pubDate>Sun, 11 Jul 2021 19:29:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:142a28e5-aea4-4b49-bbe7-0f3a8dda3d1f</guid><dc:creator>aalsubhi</dc:creator><description>&lt;p&gt;Here is the current consumption of nrf51 when spis and BLE broadcast are used:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/nrf51_5F00_spis_5F00_BLE.png" /&gt;&lt;/p&gt;
&lt;p&gt;Here is the current&amp;nbsp;consumption when I don&amp;#39;t use spis and only use BLE advertisement:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/nrf51_5F00_BLE_5F00_NOSPIS.png" /&gt;&lt;/p&gt;
&lt;p&gt;You&amp;nbsp;can see when SPIS is used nrf51 consumes around half mA even when the it is power off by the master (MSP430).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/thread/319469?ContentTypeID=1</link><pubDate>Sat, 10 Jul 2021 02:01:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34ee5ad3-ae70-436a-9f3f-4048f84b1d49</guid><dc:creator>aalsubhi</dc:creator><description>&lt;p&gt;Thank for you informative and fast response. I did some experiments to see if turning on nrf51 to send an advertisement then turn it off would work. It works fine by setting the advertisement interval to 100ms and make the MSP430 (master) wait more than 100ms (about 300ms-500ms) before cutting the power on nrf51 (slave).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; The problem I faced&lt;/strong&gt; if I enable spis on nrf51 and try to send some data, uninitiate spis to save power, &amp;nbsp;advertise the received data&amp;nbsp;and then cut the power off, &lt;strong&gt;that nrf51 VCC is hinging at 1.5V after cutting the power&lt;/strong&gt; although the spin and advertisement process are working fine, but this behavior (nrf51 is stuck at 1.4V) is causing a half amp current consumption which is very high for my system.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the other hand, If I don&amp;#39;t use spis on nrf51 and just let the BLE advertise fixed data, every 2s when master (MSP430) powering on nrf51, wait 300ms-500ms &amp;nbsp;then cut power on nrf51, the nrf51 vcc goes low near Zero volt when the power is cut off and there is no high power consumption.&lt;/p&gt;
&lt;p&gt;Here is my code :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int main(void)
{   
    // Enable the constant latency sub power mode to minimize the time it takes
    // for the SPIS peripheral to become active after the CSN line is asserted
    // (when the CPU is in sleep mode).
    NRF_POWER-&amp;gt;TASKS_CONSTLAT = 1;

    memset(m_tx_buf, 0, BUF_SIZE); // initializing  the TX buffer

    APP_ERROR_CHECK(spi_peripheral_init()); // Initialize SPI to receive sensor data from MSP430

    memset(m_tx_buf, 0, BUF_SIZE); // initializing  the TX buffer

    memset(m_rx_buf, 0, BUF_SIZE); // reset the RX buffer
    receiving_completed = false;

//    //Set buffers.
    APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&amp;amp;m_spis, m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_rx_buf)));
//
    while(!receiving_completed) // Wait for data from the Central (MSP430)
    {
        __WFE();   //stay in low power mode
    }
    nrf_drv_spis_uninit(&amp;amp;m_spis); // uninit spis to save power

    // Initialize BLE
    ble_stack_init();
    advertising_init();

    // Start execution.
    advertising_start();
    
    // Main loop.
    while(1)
    {
        
        power_manage();
    }
    
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you have any idea why using spis preventing nrf51 vcc to shutdown completely (stuck at 1.4V) when the power is off leading to a half Amp consumption?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cutting power to nrf51 after receiving spi bytes and advertising them using BLE</title><link>https://devzone.nordicsemi.com/thread/319442?ContentTypeID=1</link><pubDate>Fri, 09 Jul 2021 17:35:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55a32dbe-00e5-4698-8f25-eb736ff2ef05</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]Every 2s MSP430 derives a pin high to drive the nrf51&amp;#39;s VCC high and send multiple bytes. nrf51 after receiving the bytes through spi , tries to advertise them. &amp;nbsp;Then MSP430 waits 200 ms(after sending the multiple bytes) &amp;nbsp;before cutting the nrf51 power off.[/quote][quote user=""]Is there any way to cut the power safely on nrf51 while insuring the advertisement packet at least advertised once ?&amp;nbsp;[/quote]
&lt;p&gt;I would propose that you instead implement the nRF51 to go into SYSTEM_ON sleep mode whenever it finishes the advertisement. This way, you would know for certain that the advertisement has completed successfully, while avoiding spending time every 2 s to setup and configure the device.&lt;br /&gt;You could make use of &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/radio_notif/radio_notif.html"&gt;the Radio Notification&lt;/a&gt;&amp;nbsp;to know that a radio event has completed. If you are only doing advertising, this will be the only type of event occurring.&lt;br /&gt;&lt;br /&gt;As long as you uninitialize your peripherals and release the clocks when you are done with them, the average power consumption while in SYSTEM_ON sleep is quite low. This, combined with the time the device will have to spend every 2s in order to wake up and get ready leads me to believe that the SYSTEM_ON sleep option would give you a lower average current consumption and easier time implementing and controlling it.&lt;br /&gt;This will also reduce the time it takes to wake-up and configure the device to make it ready to receive the SPI transfer, and setup and configure the SoftDevice.&lt;br /&gt;&lt;br /&gt;Alternatively, for the lowest possible baseline current draw between transfers you could have the nRF51 go into SYSTEM_OFF sleep, and then waking it every so often through the pin interrupt - the important point here is that it should go to sleep on its own, whenever it is finished sending an advertisement, for example.&lt;br /&gt;&lt;br /&gt;If you want to cut the power to the NRF51 completely between transfers, you could have it toggle a pin to communicate that it has completed an advertising, and then cut the power.&lt;br /&gt;&lt;br /&gt;Please keep in mind that it is not guaranteed that an advertising packet will be received successfully by a central. The packet may be lost, corrupted or simply &amp;#39;not read&amp;#39; (if the central is not scanning at the particular time of the advertising).&lt;br /&gt;Advertisements have no acknowledgement, so the sender will never know if the advertisement successfully arrived at the central. However, a BLE connection is lossless, so any packets that are not acknowledged will be resent in the next connection event. If no packets are acknowledged, the link is terminated.&lt;br /&gt;&lt;br /&gt;If it is important that you do not potentially loose the data in the advertising packets I would suggest that you instead enter into a connection with a very long connection interval. If the device is in SYSTEM_ON sleep it will be ready to wake up whenever an event is generated (such as a reception on the SPI peripheral (if enabled), or an upcoming radio event).&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>