<?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 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30900/sending-30000-bytes-to-android-phone-every-30-seconds-while-uart-is-receiving-data-every-40ms</link><description>Hi all, 
 I am working on a project where the requirement is a sensor collecting data and sending to the NRF52832 via UART. Every 40ms, the NRF52832 will receive 40 bytes of data. I need to store 30 seconds worth of data in RAM (about 30000 bytes) then</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 22 Jun 2019 01:15:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30900/sending-30000-bytes-to-android-phone-every-30-seconds-while-uart-is-receiving-data-every-40ms" /><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/194166?ContentTypeID=1</link><pubDate>Sat, 22 Jun 2019 01:15:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39cf9c2c-40d3-49dd-9a2e-5faf32f35741</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Hi Aashay, sorry I never got it to work. I stop that project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/194159?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 19:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91055d63-75b3-4b80-afc5-1a5fbed33f9f</guid><dc:creator>Aashay</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/kian79"&gt;kian79&lt;/a&gt; i was wondering if you ever got a solution to work. I am trying to do something similar to this but instead of UART to mobile app, i am trying to send sensor data from UART to UART in a similar fashion. If u have a working code it would be a huge help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/126197?ContentTypeID=1</link><pubDate>Wed, 28 Mar 2018 06:24:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7562cc93-a3d4-4f21-98f0-dffabe1ee86c</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Hi MartinBL,&lt;/p&gt;
&lt;p&gt;Thanks for the help. I figure out another method to solve my problem. Using PPI with UARTE is just too complicated for me. Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/123936?ContentTypeID=1</link><pubDate>Mon, 12 Mar 2018 13:28:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93301f82-ae25-4968-bcc4-7b3c0e3e45e1</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Yes, unfortunately you can only store 255 bytes at&amp;nbsp;a time.&amp;nbsp;In other words, after 255 bytes you will have to trigger an interrupt and switch buffers. So it is possible to read a continuous stream of data, but you will have to use the CPU at 255 bytes intervals to manage the buffers and process the data. If you are able to upgrade to nRF52840 then you can use 1023 bytes long buffers instead.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Moreover, I have not been able to get PPI to work with a UARTE RX task.&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;Where are you stuck?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/123920?ContentTypeID=1</link><pubDate>Mon, 12 Mar 2018 12:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55f06c83-286d-4807-bab8-a46ad6ff29a7</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Hi MartinBL,&lt;/p&gt;
&lt;p&gt;I am revisiting this thread to clarify about the method you suggested about using EasyDMA and UART. I posted a separate thread to understand about using PPI and UARTE &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30997/understand-uart-uarte-and-getting-it-to-work-with-ppi" rel="noopener noreferrer" target="_blank"&gt;here&lt;/a&gt;. However I was told that&amp;nbsp;&lt;span&gt;the EasyDMA feature of UARTE peripheral on nRF52832 have a maximum size of 255 bytes. Does it mean that I can only store up to 255 bytes in RAM using EasyDMA? I am confuse now. Moreover, I have not been able to get PPI to work with a UARTE RX task.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122394?ContentTypeID=1</link><pubDate>Thu, 01 Mar 2018 08:36:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10056562-00c4-4c71-8088-c2d574e1fab9</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Ok, good idea.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122383?ContentTypeID=1</link><pubDate>Thu, 01 Mar 2018 05:52:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80b6b66e-0f4e-4740-aae3-e51fee11ee40</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Thanks MartinBL,&lt;/p&gt;
&lt;p&gt;I kind of understand how PPI works, but now I am totally confused by UART. There is UART HAL, UARTE HAL and UART driver. There is also Serial library.&lt;/p&gt;
&lt;p&gt;Let me start a separate thread to clear my doubts on the usage of UART first. I will revisit this thread again when I am ready to put the pieces together.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122348?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2018 16:46:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e8c7da7-5868-4fc1-9006-7764a70c057c</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;There is this&amp;nbsp;&lt;a title="PPI Example" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/ppi_example.html?cp=4_0_0_4_6_20"&gt;PPI Example&lt;/a&gt;, although I would agree that it is not the best example to show off the capabilities of PPI. However, you should take note of the naming convention of the functions, like&amp;nbsp;nrf_drv_timer_&lt;strong&gt;&lt;em&gt;event_address_get&lt;/em&gt;&lt;/strong&gt;(). You have similar functions for the UART driver: &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__nrf__drv__uart.html#gaba26bed5dfd5058ba07a180c49d96ae5"&gt;nrf_drv_uart_event_address_get&lt;/a&gt;(). Use these kind of functions to get the addresses of the tasks and &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/group__nrf__uart__hal.html#gad1710c9c8832f8d4b3264cca8029b730"&gt;events&lt;/a&gt;&amp;nbsp;and tie them together with a PPI channel using&amp;nbsp;&lt;span&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__drv__ppi.html#ga5620cf20793f2e513ed6e1db37d64721"&gt;nrf_drv_ppi_channel_assign&lt;/a&gt;().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It could be that it would be better to start with the PPI example instead of the mpu example. Start small by trying to tie a timer event to a UART TX task and see if you can send&amp;nbsp;a byte at regular intervals. Then add on with counters etc.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122237?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2018 09:03:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a496f0a-f39a-4bda-adeb-f424de2cdb89</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;it seems like I have no total clue on how to use PPI to start a transfer task from UART. I tried searching on the forum and examples, but there is no mention of it. Hope someone can shed some light on this.&lt;/p&gt;
&lt;p&gt;I have modified the codes from this example, removing the TWI portions:&lt;br /&gt;&lt;a href="https://github.com/Martinsbl/nrf5-mpu-examples/blob/master/nrf52-mpu-easydma-using-timers-and-drivers/main.c"&gt;https://github.com/Martinsbl/nrf5-mpu-examples/blob/master/nrf52-mpu-easydma-using-timers-and-drivers/main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is what I have now:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* 
  * This example is not extensively tested and only 
  * meant as a simple explanation and for inspiration. 
  * NO WARRANTY of ANY KIND is provided. 
  */

#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;nrf_drv_gpiote.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_serial.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;


/**@brief Function for initializing the nrf log module.
 */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}

NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config,
                      RX_PIN_NUMBER, TX_PIN_NUMBER,
                      RTS_PIN_NUMBER, CTS_PIN_NUMBER,
                      NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
                      NRF_UART_BAUDRATE_115200,
                      UART_DEFAULT_CONFIG_IRQ_PRIORITY);

#define SERIAL_FIFO_TX_SIZE 32
#define SERIAL_FIFO_RX_SIZE 32

NRF_SERIAL_QUEUES_DEF(serial_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);

#define SERIAL_BUFF_TX_SIZE 1
#define SERIAL_BUFF_RX_SIZE 1

NRF_SERIAL_BUFFERS_DEF(serial_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);

NRF_SERIAL_CONFIG_DEF(serial_config_dma, NRF_SERIAL_MODE_DMA,
                      &amp;amp;serial_queues, &amp;amp;serial_buffs, NULL, NULL);
											
NRF_SERIAL_UART_DEF(serial_uart, 0)


#define SERIAL_RX_BUF_LENGTH  10
#define SERIAL_RX_BUF_WIDTH   6  


/* Define a type with a two dimensioanal array, SERIAL_RX_BUF_WIDTH wide and SERIAL_RX_BUF_LENGTH long, holding a list of uart data */
typedef struct ArrayList
{
    uint8_t buffer[SERIAL_RX_BUF_WIDTH];
}array_list_t;

/* Declare an RX buffer to hold the uart data we want to read. 
 * SERIAL_RX_BUF_LENGTH defines how many samples of 
 * data we want to read out. */
array_list_t p_rx_buffer[SERIAL_RX_BUF_LENGTH];

/* Flag to indicate to the applications main context that SERIAL_RX_BUF_LENGTH number of samples have been transferred from serial */
volatile bool serial_transfers_complete = false;

/* Timer instance to trigger each read from Serial */
static nrf_drv_timer_t timer_instance_serial_start = NRF_DRV_TIMER_INSTANCE(0);

/* Counter instance to count number of transferred samples, and trigger an interrupt and wake up CPU 
 * when SERIAL_RX_BUF_LENGTH number of samples have transferred from  serial */
static nrf_drv_timer_t serial_transfer_counter_instance = NRF_DRV_TIMER_INSTANCE(1);


// Serial transfer start handler. Not used
void serial_start_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
    ;
}

// Serial transfer counter handler. 
void serial_transfer_counter_handler(nrf_timer_event_t event_type, void * p_context)
{   
		ret_code_t err_code;	
    // Set flag to start printing of samples in main loop
    serial_transfers_complete = true;
    
    // Set up next transfer sequence
    
    
    // Set flags for next transfer sequence
    
    
    // Pass configurations and flags to TWIM driver. The TWIM is now on and prepared, but not actually started.
    
	
    APP_ERROR_CHECK(err_code);
}


/**
 * @brief Serial transfer setup. This functions initiates the timer used to trigger
 * the Serial transfers. It also configures the the Serial transfers and sets up a PPI channel 
 * connecting the timer compare event with the Serial transfer start task. 
 */
static void serial_transfer_start_timer_init()
{
    ret_code_t err_code;
    // Variable to store address of timer compare event. 
    uint32_t event_address_timer_compare;
    // Variable to store address of twi start task.
    uint32_t task_address_serial_start;
    // Variable holding PPI channel number
    nrf_ppi_channel_t ppi_channel_serial_start;
    
		/********************************************* To figure out ****************************************
    // Set up next transfer sequence
    
    
    // Set flags for next transfer sequence
    
    
    // Pass configurations and flags to TWIM driver. The TWIM is now on and prepared, but not actually started.
	
	********************************************************************************************************/
    
    APP_ERROR_CHECK(err_code);
    
    // Initializing the timer triggering the Serial transfers. Passing:
    // Instance of timer
    // NULL = default timer configurations
    // Timer handler. Can not be NULL even though it is not used.
    err_code = nrf_drv_timer_init(&amp;amp;timer_instance_serial_start, NULL, serial_start_timer_handler);
    APP_ERROR_CHECK(err_code);
    
    uint32_t serial_sample_period = nrf_drv_timer_us_to_ticks(&amp;amp;timer_instance_serial_start, 40000); // Sample every 40 ms (25 Hz)
    // Configuring the timer triggering the serial transfers. Passing:
    // Timer instance
    // Capture Compare channel number
    // Sample period in micro seconds
    // Shortcut to clear timer on Capture Compare event
    // Disable the interrupt for the compare channel enabling the CPU to sleep during events
    nrf_drv_timer_extended_compare(&amp;amp;timer_instance_serial_start, (nrf_timer_cc_channel_t)0, serial_sample_period, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
    

    // Initate ppi driver. Ignore error if driver is already initialized
    err_code = nrf_drv_ppi_init();
    if((err_code != 0) &amp;amp;&amp;amp; (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED))
    {
        APP_ERROR_CHECK(err_code);
    }
    
		
		
		/************************************************************ To figure out *****************************
		
    // Get the address of the Serial start task. This is the register address of the actual Serial task. Look in the nRF52 Product Specification -&amp;gt; TWI -&amp;gt; Registers
    task_address_serial_start = nrf_drv_twi_start_task_get(&amp;amp;m_twi_instance, xfer.type);
    // Get the address of the timer compare[0] event. This is the register address of the actual timer compare[0] event. Look in the nRF52 Product Specification -&amp;gt; Timer -&amp;gt; Registers
    event_address_timer_compare = nrf_drv_timer_event_address_get(&amp;amp;timer_instance_serial_start, NRF_TIMER_EVENT_COMPARE0);
    
		*********************************************************************************************************/
		
		
		
    // Allocate a PPI channel. This function is especially useful when using a softdevice as it will ensure that the the returend PPI channels is free
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_serial_start);
    APP_ERROR_CHECK(err_code);
    
    // Connect the timer compare event and serial start task using the PPI channel
    err_code = nrf_drv_ppi_channel_assign(ppi_channel_serial_start, event_address_timer_compare, task_address_serial_start);
    APP_ERROR_CHECK(err_code);

    // Enable the PPI channel.
    err_code = nrf_drv_ppi_channel_enable(ppi_channel_serial_start);
    APP_ERROR_CHECK(err_code);
       
}

/**
 * @brief This function sets up a counter used to count serial transfers. It also sets up a PPI channel 
 * connecting the Counter increment task and the serial transfer complete event. 
 * When each serial transfer is completed the counter increments. When TWIM_RX_BUF_LENGTH number of samples is counted
 * the counter triggers an interrupt, serial_transfer_counter_handler, and wakes up the CPU.
 */
void serial_transfer_counter_init(void)
{
    // Setup serial tranfer counter
    uint32_t err_code;
    // Variable to store address of counter increment task. 
    uint32_t task_address_counter_increment;
    // Variable to store address of serial transfer complete event. 
    uint32_t event_address_serial_transfer_complete;
    // Variable holding PPI channel number
    nrf_ppi_channel_t ppi_channel_serial_transfer_count;
    
    // Set up counter with default configuration
    nrf_drv_timer_config_t counter_config = NRF_DRV_TIMER_DEFAULT_CONFIG;
    counter_config.mode = NRF_TIMER_MODE_COUNTER;
    
    // Initializing the counter counting the serial transfers. Passing:
    // Instance of counter
    // Configurations
    // Timer handler. This timer will be triggered when TWIM_RX_BUF_LENGTH number of transfers have completed.
    err_code = nrf_drv_timer_init(&amp;amp;serial_transfer_counter_instance, &amp;amp;counter_config, serial_transfer_counter_handler);
    APP_ERROR_CHECK(err_code);
    
    // Configuring the timer triggering the serial transfers. Passing:
    // Counter instance
    // Capture Compare channel number
    // Number of samples to count
    // Shortcut to clear timer on Capture Compare event
    // Use interrupts
    nrf_drv_timer_extended_compare(&amp;amp;serial_transfer_counter_instance, (nrf_timer_cc_channel_t)0, SERIAL_RX_BUF_LENGTH, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
    
    // Initate ppi driver. Ignore error if driver is already initialized
    err_code = nrf_drv_ppi_init();
    if((err_code != 0) &amp;amp;&amp;amp; (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED))
    {
        APP_ERROR_CHECK(err_code);
    }
    
    // Allocate a PPI channel. This function is especially useful when using a softdevice as it will ensure that the the returend PPI channels is free
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_serial_transfer_count);
    APP_ERROR_CHECK(err_code);
    
    // Get the address of the counter increment task. This is the register address of the actual counter task. Look in the nRF52 Product Specification -&amp;gt; Timer -&amp;gt; Registers
    task_address_counter_increment = nrf_drv_timer_task_address_get(&amp;amp;serial_transfer_counter_instance, NRF_TIMER_TASK_COUNT);
    
		
		
		/******************************************* To figure out *************************************************
		
		// Get the address of the TWI transfer complete event. This is the register address of the event. Look in the nRF52 Product Specification -&amp;gt; TWI -&amp;gt; Registers
    event_address_twi_transfer_complete = nrf_drv_twi_stopped_event_get(&amp;amp;m_twi_instance);
    
		***********************************************************************************************************/
		
		
    // Connect the serial transfer complete event and the counter increment task using the PPI channel
    err_code = nrf_drv_ppi_channel_assign(ppi_channel_serial_transfer_count, event_address_serial_transfer_complete, task_address_counter_increment);
    APP_ERROR_CHECK(err_code);

    // Enable the PPI channel.
    err_code = nrf_drv_ppi_channel_enable(ppi_channel_serial_transfer_count);
    APP_ERROR_CHECK(err_code);
}


void serial_transfer_start()
{
    // Enable the counter counting number of serial transfers
    nrf_drv_timer_enable(&amp;amp;serial_transfer_counter_instance);
    
    // Enable timer triggering serial transfers
    nrf_drv_timer_enable(&amp;amp;timer_instance_serial_start);
}

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    // Configure some LEDs
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    
    // Initialize.
    log_init();
		NRF_LOG_INFO(&amp;quot;\033[2J\033[;H&amp;quot;); // Clear screen
    
    // Start execution.
    NRF_LOG_INFO(&amp;quot;\033[2J\033[;HMPU nRF52 EasyDMA using timers and drivers example. Compiled @ %s\r\n&amp;quot;, __TIME__);
    
		ret = nrf_serial_init(&amp;amp;serial_uart, &amp;amp;m_uart0_drv_config, &amp;amp;serial_config);
    APP_ERROR_CHECK(ret);
	
    // Configure a timer to trigger serial transfers between nRF52
    serial_transfer_start_timer_init();   
    // Configure a counter to count number of serial transfers
    serial_transfer_counter_init();
	
    // Start the serial transfers between the nRF52 and uart device
    serial_transfer_start();
    
    
    uint32_t sample_nr = 0; // Variable holding number of samples read from MPU
    
    while(1)
    {
        if(NRF_LOG_PROCESS() == false)
        {
            nrf_gpio_pin_set(LED_4); // Turn LED OFF when CPU is sleeping
            
					while(serial_transfers_complete == false)
            {
                // Make sure any pending events are cleared
                __SEV();
                __WFE();
                // Enter System ON sleep mode
                __WFE();           
            }
            nrf_gpio_pin_clear(LED_4); // Turn LED ON when CPU is working
            
            // Clear terminal
            NRF_LOG_RAW_INFO(&amp;quot;\033[3;1HSample %d:\r\n&amp;quot;, (SERIAL_RX_BUF_LENGTH * ++sample_nr));
            
            // THIS FOR LOOP ASSUMES THAT TWIM_RX_BUF_WIDTH IS 6 BYTES AND THAT ONLY ACCELEROMETER DATA IS SAMPLED
            // IF A WIDER BUFFER IS USED TO SAMPLE TEMPERATURE AND GYROSCOPE AS WELL YOU SHOULD CHANGE THIS LOOP
            // TO PRINT EVERYTHING
            uint8_t *data;
            // Itterate through entire RX buffer 
            for(uint8_t j = 0; j&amp;lt;SERIAL_RX_BUF_LENGTH; j++)
            {
                // Print sensor data set
                NRF_LOG_RAW_INFO(&amp;quot;&amp;quot;);
                nrf_delay_ms(1); // Small delay
            }
            // Reset data ready flag
            serial_transfers_complete = false;
        }
    }
}

/** @} */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122143?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 13:59:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e2a35b0-af41-4926-9074-631d5c5272b8</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Good point.&amp;nbsp;S132 v5.1 &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/mem_usage/mem_resource_reqs.html?cp=2_3_1_0_13_0_0"&gt;requires 4.6kB of RAM&lt;/a&gt; alone, so 60k&amp;nbsp;of buffers is out of the question.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122127?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 12:38:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3630e028-4849-412c-acd2-aa663128f468</guid><dc:creator>kian79</dc:creator><description>&lt;p&gt;Thanks MartinBL!&lt;/p&gt;
&lt;p&gt;I think I found an example which is somewhat similar to what you had described, except this uses TWI:&lt;br /&gt;&lt;a href="https://github.com/Martinsbl/nrf5-mpu-examples/tree/master/nrf52-mpu-easydma-using-timers-and-drivers"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Martinsbl/nrf5-mpu-examples/tree/master/nrf52-mpu-easydma-using-timers-and-drivers"&gt;https://github.com/Martinsbl/nrf5-mpu-examples/tree/master/nrf52-mpu-easydma-using-timers-and-drivers&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I should be able to use these codes as a starting point. On a side note, having a secondary buffer would mean having to reserve 60k of RAM. Is this even possible? There is only 64k of RAM on the nrf52832.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending 30000 bytes to Android Phone every 30 seconds while UART is receiving data every 40ms</title><link>https://devzone.nordicsemi.com/thread/122047?ContentTypeID=1</link><pubDate>Tue, 27 Feb 2018 07:14:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b646b66-8da6-42b1-b5a9-56e2822a141e</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It sounds like using your UART with &lt;a title="EasyDMA" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uarte.html?cp=2_1_0_34_1#concept_l5y_hcm_wr"&gt;EasyDMA&lt;/a&gt;&amp;nbsp;combined with a timer, a counter, and some&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/ppi.html?cp=2_1_0_21#concept_sxf_21l_1s"&gt;PPI&lt;/a&gt;&amp;nbsp;channels could solve your problem. In short, you can set up a timer to trigger an event every 40ms and connect this via PPI to a transfer task in your UART. You can then use EasyDMA and let the UART transfer data directly to a buffer in RAM. Use the counter to count the number of transfers and fire an interrupt when you have enough data to send. You can do all these things completely autonomously, without using the CPU and hence, not block any BLE transfers. After 30k samples, when it is time to transfer your data, the counter interrupt triggers, you swap your buffer to a secondary one and then start transferring your first buffer.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>