<?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>Equation result is not as expected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27532/equation-result-is-not-as-expected</link><description>Hello, 
 there is an equation in the code where I see that variable: deviceid is: 229 and var_temp is also: 229. 
 But the debugging shows that the Mikrocontroller is going into this if-case. I cant understand why. Both variables are uint8_t and have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Nov 2017 23:36:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27532/equation-result-is-not-as-expected" /><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108721?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 23:36:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2cee4e4-d891-4a2a-a96e-38e418df5e2b</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;Thank you very much for your help. I think I should try this twi driver in blocking mode. That sounds very robust. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108720?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 23:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a60ae53-10fd-4f9a-adf2-43c7260f2d61</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;so wait for the RX event then before continuing, or use the twi driver which does all this for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108719?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 23:26:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:570f954d-6770-4ce8-9ac5-8beb20d7ef1d</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;No sorry I am not using this Code what you think. I coded my own little driver with all registers which are explained in the TWIM chapter (&amp;quot;33 TWIM — I2C compatible two-wire interface master
with EasyDMA&amp;quot;)  in this document: &amp;quot;nRF52832 Product Specification v1.4&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108718?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 23:10:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49ff3f15-0429-4271-bb24-cedae4644e86</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;You&amp;#39;re clearly using the TWIM driver, so go and read the chapter about the TWIM driver in &amp;#39;Hardware Drivers&amp;#39; which explains the code you&amp;#39;re using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108717?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 23:04:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fb63671-f751-42be-bbe7-cfe2b34cf931</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;Thank you for your answer. Ok, of course I am going to read more about twi handler. But I am using TWIM0 (Twi Master) at the moment. And in this chapter of NRF52832 says nothing about Blocking Mode or something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108716?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 22:59:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:463287c1-9cd9-4fd3-b401-4662b5f29359</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;please go and read the documentation on the twi handler you&amp;#39;re using, it&amp;#39;s very comprehensive and will tell you all about how to initialize the driver in blocking as opposed to non-blocking mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108715?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 22:57:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d087457-98af-4115-90fb-c40c8cd677ae</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;Yes that seems to be the explanation why the data is not available.&lt;/p&gt;
&lt;p&gt;But how can I know when the data is available? How can I use this feature what you call &amp;quot;the blocking mode&amp;quot;  ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108714?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 20:57:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03a253dc-7d14-4da7-9e51-d1f7fd67cc3b</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;fairly obvious guess is that you&amp;#39;ve enabled the TWIM in non-blocking mode giving it a callback however you&amp;#39;re using it as if it were in blocking mode in that code expecting the data to be available as soon as the twim rx call completes.&lt;/p&gt;
&lt;p&gt;That also explains why the debugger shows the values equal because, by the time you get to look at them in the debugger, the data has been transferred.&lt;/p&gt;
&lt;p&gt;If you want blocking mode then use that, if you want callback mode, put your code in the callback.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108724?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 19:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32939627-1b42-4d57-b382-69e60e57c52b</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;And the equation also works If I add a whait time of 5ms before the if case code segment.
At the moment I dont understand why I have to do this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108723?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 19:36:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79cda1c2-8823-4e0d-bd8e-8ea7e8d92cc4</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;Now I made another discovery. If I stop the running with a debug mark at this point:
if (return_eok == 0)&lt;/p&gt;
&lt;p&gt;and after this debug mark I start running again.
The equation is working.&lt;/p&gt;
&lt;p&gt;If I dont have this debug mark at this point and I only have a debug-mark after the code segment I gave you the equation is not working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108726?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 17:01:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:904f1dac-4f04-4278-afea-381bb07b0249</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;No. I am not working with the official SDK Board.
I have built my own Prototype/Evaluation Board.
So I am going to check the SDK examples configruation.&lt;/p&gt;
&lt;p&gt;What I did: I took the default configuration for the NRF52832 in the Segger Studio IDE.&lt;/p&gt;
&lt;p&gt;What I discovered is that it doesnt matter which value I give this equation. Its always true.
So its like the Mikrocontroller doesnt get this right value for the equation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108725?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 16:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af1144a-5c4c-4522-bc6b-a1eedc98af76</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Are you using the same compiler settings as we do in our default SDK examples?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108722?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 15:57:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b17040d1-20e7-49ec-8620-8bc81c24385d</guid><dc:creator>Fifty1</dc:creator><description>&lt;p&gt;Yes its very strange.&lt;/p&gt;
&lt;p&gt;I am reading the DeviceID from an accelerator sensor.
I tried several solutions (equation with uint8_t variable, with Makro, with hexvalue). Nothing is working. CPU is going always in this if case.&lt;/p&gt;
&lt;p&gt;In Segger IDE it says that deviceid is the same value (0x33) as the Makro or other variable.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  uint8_t deviceid = 0;

    // read device ID
        if ((nrf52810_drv_twim0_rx_data((uint8_t) LIS3DH_I2C_DEVICE_ADDRESS, (uint8_t) WHO_AM_I, &amp;amp;deviceid, sizeof(deviceid))) != 0)
        {
           return_eok |= ERROR_BIT_0;
        }
            
        if (return_eok == 0)
        {
           if (deviceid != LIS3DH_VALUE_DEVID)
           {
              return_eok |= ERROR_BIT_1;
           }
        }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Maybe there is something wrong with Compiler Settings or something like this. Its like I see in Segger IDE not the same what the Mikrocontroller gets from the compiler (as assembler code).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Equation result is not as expected</title><link>https://devzone.nordicsemi.com/thread/108713?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 13:27:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:084387e6-50c7-4f84-92e9-81551f507f81</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Thats strange. Are you able to post more of your code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>