<?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>Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21510/problem-sending-6-bytes-to-multiple-services-using-sd_ble_gatts_hvx</link><description>I would like to confirm my understanding of Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx 
 I use nrf52832 sdk13.0.0 
 BLE SPI is master. I dropped the SCK to 1 Mhz
I send x18 bytes of data to slave, just to generate the SPI clock</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Apr 2017 13:26:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21510/problem-sending-6-bytes-to-multiple-services-using-sd_ble_gatts_hvx" /><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84433?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2017 13:26:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4595cd4a-d1c5-42b1-9498-383c4e9563aa</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Petter,&lt;/p&gt;
&lt;p&gt;I think the         while (!spi_xfer_done)
{
__WFE();
}
is causing problems. I removed the __WFE(); inside of the timer update, but still no go.&lt;/p&gt;
&lt;p&gt;The only way I could get SPI to function correctly, was to leave it in the main loop, and place an if() around it, so set a flag inside the timer event, so the main() loop will the do the SPI transfer.&lt;/p&gt;
&lt;p&gt;It works, so all I can say is unless the SPI was stopped, the asynchronous SPI reads with the Timer 1sec interrupt, does not work.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84435?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2017 06:50:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a2a9ef9-864c-4649-be2b-919d22eea120</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I&amp;#39;m not exactly sure what is going on here, and even if you shared your code it would be a bit difficult to test it. Can&amp;#39;t you just have a 2, 3 or 5 second timer and start the SPI transfer from the timer? And when the SPI transaction is complete you update the characteristics?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84434?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2017 03:23:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:961d71da-0f99-4629-a7ef-bf6b7bf95cc7</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;I still have problems with updating characteristics to quickly.
If I call the three (3) characteristic updates in the main() loop, it works.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;our_termperature_characteristic_update(&amp;amp;m_our_service, &amp;amp;testchar[12]);
sr2_termperature_characteristic_update(&amp;amp;m_sr2_service, &amp;amp;testchar[6]);
sr3_termperature_characteristic_update(&amp;amp;m_sr3_service, &amp;amp;testchar[0]);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I call it from the static void timer_timeout_handler(void * p_context)&lt;/p&gt;
&lt;p&gt;then the SPI info is out of sync.
So it seems because SPI is updated through an interrupt, (not DMA it seems), SPI info is correct right after
while (!spi_xfer_done)&lt;/p&gt;
&lt;p&gt;But if I call my service characteristic updates
from
timer_timeout_handler(void * p_context)
Since it is asynchronous with SPI events, I get shifted SPI info.
So by the time the timer happens, SPI has updated some values, but not all.&lt;/p&gt;
&lt;p&gt;It is still correct information, it is just shifted in the buffer, so say val[1] holds val[5] info.&lt;/p&gt;
&lt;p&gt;The problem is that I place a nrf_delay_ms(500); in the main loop, so the updates happens very quickly.
I&amp;#39;ve seen on a iPhone 4s that after a while, the screen starts flickering as updates happen.&lt;/p&gt;
&lt;p&gt;So I need to slow the updates down, 1sec or even 5 second update rate is fine.&lt;/p&gt;
&lt;p&gt;I saw a suggestion to uninit the SPI, but that did not seem to work.&lt;/p&gt;
&lt;p&gt;I need a way to update every say 2 or 3 or 5 seconds, but know when SPI has the correct info.&lt;/p&gt;
&lt;p&gt;Any help appreciated&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84432?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:23:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a235904c-dae5-4e5c-96e3-0c1d9d8aa353</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;I guess either stop the SPI, or only call nrf_drv_spi_transfer to update the rx_Buffer, and then update the characteristics.
Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84431?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 12:20:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20998aea-b474-48b0-8471-cc9089b96824</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Petter,&lt;/p&gt;
&lt;p&gt;I believe I found the issue.&lt;/p&gt;
&lt;p&gt;I was calling the characteristic updates from inside the 1sec timer routine.&lt;/p&gt;
&lt;p&gt;So I think the SPI is free running, (in the main while loop) so it updates all the time.&lt;/p&gt;
&lt;p&gt;During the time the 1sec timer interrupts, the SPI may have updated.
So I moved the characteristic update calls to right after the nrf_drv_spi_transfer&lt;/p&gt;
&lt;p&gt;FIXED!!
A hack a day keeps the doctor away.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem sending 6 bytes to multiple services using sd_ble_gatts_hvx</title><link>https://devzone.nordicsemi.com/thread/84430?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2017 09:05:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3b65e7f-6aed-4905-8610-8c18c3c58e75</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;So you have made 3 services with one characteristic in each? What exactly fails? Do you get any error inside our_temperature_characteristic_update()? Have you tried to use the debugger to see what happens? Does the chip reset? The last code piece you included seems to me incomplete, is this on purpose?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>