<?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>Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117964/ring-buffer-maximum-size</link><description>Hello, 
 I&amp;#39;m reading about 700 values from an LSM6SDO gyro/accelerometers per second and need to store them, before sending them over bluetooth once where I store them is full. I briefly looked into flash storage, but it seems like ring buffers are the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Jan 2025 11:55:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117964/ring-buffer-maximum-size" /><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518614?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2025 11:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f6bd5bd-59ab-4458-8a98-ddb3bbf58ab9</guid><dc:creator>Charlie</dc:creator><description>[quote user="connorshannon"]1. Why is the nRF52840 a better option than the nRF52832? Does it have more RAM storage available?[/quote]
&lt;p&gt;Yes. You can find following comparison from&amp;nbsp;&lt;a href="https://www.nordicsemi.com/Products/Wireless/Bluetooth-Low-Energy"&gt;Bluetooth Low Energy (Bluetooth LE) - nordicsemi.com&lt;/a&gt;. You can even consider nRF5340 if the only concern is RAM size..&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2025_2D00_01_2D00_16-093105.png" /&gt;&lt;/p&gt;
[quote user="connorshannon"]2. According to the ring buffer library, ring buffers are declared using RING_BUF_DECLARE which will &amp;quot;&lt;span&gt;declare and statically initialize a ring buffer with a specified byte count.&amp;quot; I want to make this as many bytes as are available in RAM, but I still don&amp;#39;t know how to do this. Should I just use an arbitrarily large number and assume that it will&amp;nbsp;allocate what is available? Is there a way to find out how many bytes are available for use in RAM?&lt;/span&gt;[/quote]
&lt;p&gt;Yes, it is possible to monitor the RAM usage by your application, then you can adjust your ring buffer size accordingly. I have shared methods on the following thread:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/support-private/support/338302#permalink=1028675"&gt;https://devzone.nordicsemi.com/support-private/support/338302#permalink=1028675&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518529?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2025 00:23:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2de57c36-0fe2-4d2c-a188-4c09a18e2ca0</guid><dc:creator>connorshannon</dc:creator><description>&lt;p&gt;Apologies for my continued confusion, but I still have a few questions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Why is the nRF52840 a better option than the nRF52832? Does it have more RAM storage available?&lt;/p&gt;
&lt;p&gt;2. According to the ring buffer library, ring buffers are declared using RING_BUF_DECLARE which will &amp;quot;&lt;span&gt;declare and statically initialize a ring buffer with a specified byte count.&amp;quot; I want to make this as many bytes as are available in RAM, but I still don&amp;#39;t know how to do this. Should I just use an arbitrarily large number and assume that it will&amp;nbsp;allocate what is available? Is there a way to find out how many bytes are available for use in RAM?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518406?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2025 09:55:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e4073d1-af97-4d97-ad72-fc8e5e5a9c0d</guid><dc:creator>Charlie</dc:creator><description>[quote user="connorshannon"]it is solely how to store the most data possible in RAM, whether that be through making multiple ring buffers or just one large one.[/quote]
&lt;p&gt;I would recommend using a single ring buffer unless there are specific reasons to justify multiple buffers. If your goal is to store as much data as possible in RAM, you might want to consider using a chip like the nRF52840 instead of the nRF52832. The amount of ring buffers doesn’t significantly impact the storage capacity compared to the RAM availability.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518330?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2025 21:12:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1e3ae9d-5da8-48ca-8f84-08516c9069b0</guid><dc:creator>connorshannon</dc:creator><description>&lt;p&gt;No worries. I just want to clarify again - it isn&amp;#39;t the speed of the bluetooth process I am interested in here, it is solely how to store the most data possible in RAM, whether that be through making multiple ring buffers or just one large one. I am still in confusion about this, but will continue to search other documentation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518240?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2025 10:38:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c70c041-3e20-415c-a0b6-2457555c5427</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Apologies for the confusion in my previous message. I mentioned 2 Mbps, but I had kbps in mind due to another audio project I’m working on.&lt;/p&gt;
&lt;p&gt;While the actual throughput may be lower than the theoretical 2 Mbps, it should still be sufficient for your application. For more details on this topic, you can refer to&lt;/p&gt;
&lt;p&gt;&lt;a style="font-family:inherit;" href="https://novelbits.io/bluetooth-5-speed-maximum-throughput/"&gt;Bluetooth 5 Speed: How to Achieve Maximum Throughput&lt;/a&gt;&lt;span style="font-family:inherit;"&gt;&amp;nbsp;which explains deatails on this topic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I think next step you can refer the ring buffer sampels on NCS code base to have a try.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518187?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2025 14:56:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:654dde0c-d050-421f-82c8-61fdc3d7ec2c</guid><dc:creator>connorshannon</dc:creator><description>&lt;p&gt;Thank you for the response. I&amp;#39;m still not sure that this fully solves my issue. My plan is to use the maximum buffer size possible, wait until it is full, and then stop recording data and send what is in the buffer over bluetooth. The main question that I had was the best way to allocate the &amp;#39;most&amp;#39; possible memory to the ring buffer (make it as large as possible so I can store more data). Also, you said the maximum data transfer rate was 2Mbps, which as far as I know is 2,000,000 bps. I don&amp;#39;t really understand how my data rate (~448,000 bps) exceeds that. Some clarification might be helpful. Thank you again for the help!&lt;/p&gt;
&lt;p&gt;Also - I am using VSCode, C language, and the nRF52832 chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ring Buffer Maximum Size</title><link>https://devzone.nordicsemi.com/thread/518139?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2025 12:16:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a615e32-0688-40ff-b0fd-6589286bfd9e</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for inqurying with us about your application design questions. It is out of supporting scope but I want to share some of my through about your current chanelleges.&lt;/p&gt;
&lt;p&gt;1. You current data input is 700x64bit(double value)/s=448000bps, cosidering you are use BLE 2Mbps data rate. The system produced much more data than it can consume. You have to consider decrease data proudction rate or increase comsumer capability, otherwise, there is not so much meaning to use ring buffer, whcih only make sure you can will send latest data chunk per BLE date sending interval, but most of old is droped by ring buffer.&lt;/p&gt;
&lt;p&gt;2. I am not sure where you get the information,&amp;nbsp;&lt;span&gt;one ring buffer can only hold 64 words worth of information is not ture. The ring buffer size is only limited by the RAM size you can assign for ring buffer.&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.9.0/page/zephyr/kernel/data_structures/ring_buffers.html"&gt;Ring Buffers&lt;/a&gt;&amp;nbsp;descrips the ring buffer usage. You can search&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;ring_buf_init in NCS code base to find serveral real ring buffer usage in samples.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;Thank you for inquiring about your application design questions. While this is outside our official support scope about specific application design, I’d like to share some thoughts regarding your current challenges:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data Input vs. Throughput&lt;/strong&gt;&lt;br /&gt;Your current data input rate is calculated as 700 × 64 bits (double value) per second = &lt;strong&gt;448,000 bps&lt;/strong&gt;. Considering if you are using the BLE with the maxium 2 Mbps data rate, your system generates far more data than it can handle. To address this, you’ll need to either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Decrease the data production rate, or&lt;/li&gt;
&lt;li&gt;Increase the data consumer capability.&lt;br /&gt;Without making these adjustments, the ring buffer will primarily ensure that the latest data chunk is sent per BLE interval, but a significant amount of older data will be dropped.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ring Buffer Size Misconception&lt;/strong&gt;&lt;br /&gt;The idea that a ring buffer can only hold 64 words of information is &lt;strong&gt;not accurate&lt;/strong&gt;. The size of the ring buffer is determined solely by the amount of RAM allocated to it. For further details, you can refer to the Zephyr&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-2.9.0/page/zephyr/kernel/data_structures/ring_buffers.html"&gt;Ring Buffers&lt;/a&gt;&amp;nbsp;documentation.&lt;/p&gt;
&lt;p&gt;You can also look for &lt;strong&gt;&lt;code&gt;ring_buf_init&lt;/code&gt;&lt;/strong&gt; in the NCS codebase to find examples of how ring buffers are used in various samples.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I hope this helps provide clarity. Let me know if you need further assistance.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>