<?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>undefined reference twi error</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63114/undefined-reference-twi-error</link><description>Hi, 
 
 I hope you can help me. I get an error while compiling. I merge &amp;quot;twi sensor&amp;quot; example from sdk to the &amp;quot;ble app uart&amp;quot; example from sdk. So I customize the sdk_config to enable twi. In addition to that, I add all missing nRF_Drivers to make it work</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Sep 2020 07:33:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63114/undefined-reference-twi-error" /><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/271442?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 07:33:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66b0733f-f563-4bc4-8cb8-7564359dcb56</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote userid="88554" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/271136"]Yes, you´re right. So because of my Questions are answered well we can close this thread.[/quote]
&lt;p&gt;Great, please do not hesitate to open a new ticket if you should encounter any issues or questions in the future!&lt;/p&gt;
[quote userid="88554" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/271136"]I say thank you for your great support regarding our nrf52833 product development.[/quote]
&lt;p&gt;I am glad to hear you say that Simon, thank you!&lt;br /&gt;It is no problem at all, I am happy to help.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/271136?ContentTypeID=1</link><pubDate>Wed, 23 Sep 2020 14:14:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b127016-1aa7-46cd-88ac-f62148e05706</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/270492"]The reason why I ask you to create a new ticket for new questions is to keep the forum tidy, and easy to navigate for other users.[/quote]
&lt;p&gt;Yes, you&amp;acute;re right. So because of my Questions are answered well we can close this thread. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I say thank you for your great support regarding our nrf52833 product development.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/270492?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 08:32:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4574a621-4d02-4af1-b4da-05eb0055e2d8</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]The last days I optimized the application (finding the best timing/timer parameters, making the code better to read, delete all &amp;quot;nrf_delay&amp;quot; functions from code, ...) and I think we have a good running solution now.[/quote]
&lt;p&gt;I am happy to hear that you now have a good solution running! :)&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]I exactly done it like this. So, now the TWIM prodecure starts with BLE event connected and stops with BLE event disconnected. Thats fine.[/quote]
&lt;p&gt;This is a good way of handling it, very well.&lt;/p&gt;
[quote user="simon1516"]I have another question and hope you can help me with that, too.[/quote]
&lt;p&gt;If you have more questions that diverge from your original ticket, I would ask that you create a separate ticket for that. If you would like for me to help you specifically - for example if the question is somehow related to a previous ticket, or requires insight into a project that I already know -&amp;nbsp; then you may tag me in the new ticket, or ask for me to handle it specifically. I can not guarantee that I will be assigned to it, but it will be a lot more probable.&lt;br /&gt;The reason why I ask you to create a new ticket for new questions is to keep the forum tidy, and easy to navigate for other users.&lt;br /&gt;&lt;br /&gt;With that said, I will finish answering the questions you asked in your previous comment:&lt;/p&gt;
[quote user="simon1516"]First I would like make sure, that this is possible without any external hardware. VDDH is divided by 5 by default, so I think there is a voltage divider already there (it is called as &amp;quot;&lt;span style="font-family:monospace;font-size:10.323px;left:172.56px;top:293.388px;"&gt;&lt;span&gt;VDDHDIV5&lt;/span&gt;&lt;/span&gt;&amp;quot;, &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF52833_PS_v1.3.pdf"&gt;https://infocenter.nordicsemi.com/pdf/nRF52833_PS_v1.3.pdf&lt;/a&gt; p. 359). Could you confirm this?[/quote]
&lt;p&gt;Yes, I can confirm that the SAADC may measure the VDDH pin without external hardware. The voltage is here divided by 5, since the potential input to the VDDH might exceed the nRF52833&amp;#39;s absolute maximum electrical ratings.&amp;nbsp;&lt;br /&gt;You can read more about this in &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52833%2Fsaadc.html"&gt;the nRF52833 SAADC documentation&lt;/a&gt;.&lt;/p&gt;
[quote user="simon1516"]For ADC input channel i used VDD and VDDH for testing the result. In case of VDD (1,8V), I get an output of about decimal 500. In case of VDDH (battery, 4,05V in this test) I get an output of about decimal 1150. This makes sense, because 4,05/1150 is approximately the same like 1,8/500. So I´m measuring good values :-)[/quote]
&lt;p&gt;I can not say anything about these values you are seeing, since I do not know how you have configured you channels, etc.&lt;/p&gt;
[quote user="simon1516"]My question here: In example I just can see, that default setting for SAADC are used (for nrf_drv_saadc_init). How can I see the values for resolution, oversample and so on?)[/quote]
&lt;p&gt;These default values are defined in the sdk_config file. You may jump to these values quickly in Segger Embeded Studios by right clicking them, and selecting &amp;quot;go to definition&amp;quot; at the top, this will take you directly to their definition in the sdk_config.&lt;br /&gt;Please note that channel configuration matters just as much as SAADC configuration, and you will have to have an acquisition time of &amp;gt;= 10 ms for the VDDH channel, as per the SAADC documentation.&lt;/p&gt;
[quote user="simon1516"]In case of battery voltage is less than 2,5V (adjustable), than the battery should not be used furthermore because of security reasons.[/quote]
&lt;p&gt;Do you here mean&amp;nbsp;&lt;em&gt;safety&amp;nbsp;&lt;/em&gt;reasons?&lt;br /&gt;Dead Li-Po cells is a safety hazard, if they are allowed to deeply discharge. I suspect that this is what you meant, but I emphasize this regardless, due to its importance.&lt;/p&gt;
[quote user="simon1516"]In case of the battery is charged enough, the application should be working again. The chip should be waking up automatically, allthough the chip isn´t powered to this time. Is this possible?&amp;nbsp;[/quote]
&lt;p&gt;The SAADC will give you good ballpark&amp;nbsp;&lt;em&gt;estimates&lt;/em&gt; of the remaining battery, but it is not pinpoint accurate. If you require high accuracy readings of the state of charge / health of the battery, I would suggest looking into adding a Low Power fuel gauge IC to your project.&lt;br /&gt;That being said, the SAADC gives good enough readings for most use-cases of battery readings ( but this also depends on what else your device will be doing at the time ).&lt;br /&gt;&lt;br /&gt;Without external circuitry there is not way for the chip to wake up automatically when it is above a certain charge level - if it is to do these measurements itself, it will also have to wake up to discover that it has gone below its limits.&lt;br /&gt;So, in short; No, if the nRF is doing its own battery voltage readings - and is using those readings to determine if it has within the operating levels - it is no way for it to avoid waking up to check the level when it is outside those limits.&lt;br /&gt;You may however set this limit higher than its absolute limit, so that you may know when you are approaching it, and act accordingly.&lt;br /&gt;I recommend reading &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/12287/nrf52-saadc-noise#post-id-70166"&gt;this ticket&lt;/a&gt;, for more information about noise during SAADC measuring.&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/270426?ContentTypeID=1</link><pubDate>Sun, 20 Sep 2020 15:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:191788aa-fb67-499d-8efd-6be76c931075</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;here I am again :-)&lt;/p&gt;
&lt;p&gt;The last days I optimized the application (finding the best timing/timer parameters, making the code better to read, delete all &amp;quot;nrf_delay&amp;quot; functions from code, ...) and I think we have a good running solution now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268859"]So, you can add such a variable to the ble_evt_handler in the CONNECTED and DISCONNECTED events, for instance.[/quote]
&lt;p&gt;I exactly done it like this. So, now the TWIM prodecure starts with BLE event connected and stops with BLE event disconnected. Thats fine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have another question and hope you can help me with that, too. We would like to monitor battery state. We use a single cell, connected to VDDH with an input range of the battery of 2,5V - 4,2V.&lt;/p&gt;
&lt;p&gt;- First I would like make sure, that this is possible without any external hardware. VDDH is divided by 5 by default, so I think there is a voltage divider already there (it is called as &amp;quot;&lt;span style="font-family:monospace;font-size:10.323px;left:172.56px;top:293.388px;"&gt;&lt;span class="highlight selected"&gt;VDDHDIV5&lt;/span&gt;&lt;/span&gt;&amp;quot;, &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF52833_PS_v1.3.pdf"&gt;https://infocenter.nordicsemi.com/pdf/nRF52833_PS_v1.3.pdf&lt;/a&gt; p. 359). Could you confirm this?&lt;/p&gt;
&lt;p&gt;- I have already build the SAADC example. For ADC input channel i used VDD and VDDH for testing the result. In case of VDD (1,8V), I get an output of about decimal 500. In case of VDDH (battery, 4,05V in this test) I get an output of about decimal 1150. This makes sense, because 4,05/1150 is approximately the same like 1,8/500. So I&amp;acute;m measuring good values :-) My question here: In example I just can see, that default setting for SAADC are used (for nrf_drv_saadc_init). How can I see the values for resolution, oversample and so on?)&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7484.1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- and last question: In case of battery voltage is less than 2,5V (adjustable), than the battery should not be used furthermore because of security reasons. The Chip should power down than. In case of the battery is charged enough, the application should be working again. The chip should be waking up automatically, allthough the chip isn&amp;acute;t powered to this time. Is this possible?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268859?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 07:16:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:604276e1-277e-48aa-adb1-85391473bac9</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]Is it okay notice this for later? I´m happy that the main things are working now. I´m sure that both things are making sense :-)[/quote]
&lt;p&gt;Absolutely, you can jot this down for later, as a possible optimization of your application. It is great to hear that you are happy with how things are working currently!&lt;br /&gt;In short, you might optimize this application by using the REPEATED_XFER flag with the nrfx_twim_xfer. This will make it so that a given transfer happens every so often.&lt;br /&gt;You may then set it up so that your peripheral does not transmit the value if there has not been a significant change ( I do not know exactly what you are measuring and / or how fast it will fluctuate ) but you may do this by setting &lt;em&gt;slave latency&amp;nbsp;&lt;/em&gt;in your connection parameters. This can also save you a lot of power.&lt;/p&gt;
[quote user="simon1516"]I just added the call &amp;quot;idle_state_handle()&amp;quot; in my main loop. I´m excited to see the impact to the current consumptation. I wasn´t able to measure this yet.[/quote]
&lt;p&gt;Great, I look forward to hearing the results!&lt;/p&gt;
[quote user="simon1516"]Unfortunaly I have another problem with my connection: If I rebuild/repower the Dev. board I can see the application in nRF connect as BLE device - as it should be. But if I wait a short time, sometimes 20s, sometings 30s, the device can´t be found furthermore. The same if I connect to the device and then disconnect - I can´t found the device furthermore.[/quote]
&lt;p&gt;Hm, this sounds like the device is not advertising anymore.&lt;br /&gt;What is your advertising parameters? Have you set a timeout for the advertisement?&lt;/p&gt;
[quote user="simon1516"]I think this is because of the TWIM transfer - so many transfers (every 10 or 20ms) to read from the sensor, print over uart and send ober BLE...is the application able to advertise, allthough the CPU has to do such many tasks? I seems not. So my question here: Is there a variable I can use to indicate if the TWIM shall work or not?[/quote]
&lt;p&gt;Yes, you do not need to worry that the CPU will not be able to fulfill the SoftDevice requirements. As mentioned earlier, the SoftDevice takes priority over any application layer task, which means that when the SoftDevice needs the CPU for time-critical tasks it will take it, no matter what the application is doing.&lt;br /&gt;So, it is actually the other way around which you will need to think about - how will your application behave if interrupted during a certain operation - this is important to take into account when developing the application.&lt;br /&gt;You can create a variable to stop reading / trying to send the TWI transfers when you are in a connection or not - this is probably wise, since there is no use in collecting the sensor data if you can not send it to anyone ( if you are not buffering it ).&lt;br /&gt;So, you can add such a variable to the ble_evt_handler in the CONNECTED and DISCONNECTED events, for instance.&lt;/p&gt;
[quote user="simon1516"]Thanks for helping me with all my problems![/quote]
&lt;p&gt;It is no problem at all, Simon!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268809?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 17:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71d1b39e-93d2-48c8-bc86-8c5343966819</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268635"]After initialization of the sensor, what else than reading the sensor data do you do?[/quote]
&lt;p&gt;Nothing. I just want to collect the sensor data and transmitt them by BLE. Nothing else.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268635"]Regarding that last part, have you looked at the possibility to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=ga07a7b732d1b87b714338fccce09996bc"&gt;_TXRX&lt;/a&gt;&amp;nbsp;DESC type? It sets up two transfers, one write and one read. Alternatively, if you are always doing the same read/write operation periodically, you could use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrfx__twim.html#ga2bf5386fc2e5421da9d6d265e5deef83"&gt;NRFX_TWIM_FLAG_REPEATED_XFER&lt;/a&gt;&amp;nbsp;flag for the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=gae53a1bebcd5961e1cd7a79e4039b8c88"&gt;nrfx_twim_xfer&lt;/a&gt;. This way, you can queue a lot of these transfers to happen periodically.[/quote]
&lt;p&gt;Is it okay notice this for later? I&amp;acute;m happy that the main things are working now. I&amp;acute;m sure that both things are making sense :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268635"]You already have the idle_state_handler implemented in your project - it came with the example you started out from. Just search for&amp;nbsp;&lt;em&gt;idle_state_handler&lt;/em&gt; in your main.c and you will see![/quote]
&lt;p&gt;I just added the call &amp;quot;idle_state_handle()&amp;quot; in my main loop. I&amp;acute;m excited to see the impact to the current consumptation. I wasn&amp;acute;t able to measure this yet.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Unfortunaly I have another problem with my connection: If I rebuild/repower the Dev. board I can see the application in nRF connect as BLE device - as it should be. But if I wait a short time, sometimes 20s, sometings 30s, the device can&amp;acute;t be found furthermore. The same if I connect to the device and then disconnect - I can&amp;acute;t found the device furthermore.&lt;/p&gt;
&lt;p&gt;I think this is because of the TWIM transfer - so many transfers (every 10 or 20ms) to read from the sensor, print over uart and send ober BLE...is the application able to advertise, allthough the CPU has to do such many tasks? I seems not. So my question here: Is there a variable I can use to indicate if the TWIM shall work or not?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If variable (BLE device connected)&lt;/p&gt;
&lt;p&gt;then TWIM transfer&lt;/p&gt;
&lt;p&gt;endif&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then the CPU can take it&amp;acute;s time for advertising because there are no other tasks to do.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for helping me with all my problems!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268635?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 06:46:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:517db8ef-11f8-4a3b-8c76-88decb7ac4e9</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]Thanks for this. So it make sense, setting CPU in sleep mode. I will try it :-)[/quote]
&lt;p&gt;Great, I am happy to hear that you found the reference helpful! :)&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]My timers are working now, I get it! :-) In my case I call two times &amp;quot;nrfx_twim_xfer&amp;quot; in one read procedure. Because of that, I have declared two timers now. I had to split my read function in two parts (because a timer can just call one function after expiration).[/quote]
&lt;p&gt;Its working, great!&lt;br /&gt;I am not sure I have completely understood the usage of the TWIM transfers here then.&lt;br /&gt;After initialization of the sensor, what else than reading the sensor data do you do?&lt;br /&gt;&lt;br /&gt;Regarding that last part, have you looked at the possibility to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=ga07a7b732d1b87b714338fccce09996bc"&gt;_TXRX&lt;/a&gt;&amp;nbsp;DESC type? It sets up two transfers, one write and one read. Alternatively, if you are always doing the same read/write operation periodically, you could use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrfx__twim.html#ga2bf5386fc2e5421da9d6d265e5deef83"&gt;NRFX_TWIM_FLAG_REPEATED_XFER&lt;/a&gt;&amp;nbsp;flag for the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=gae53a1bebcd5961e1cd7a79e4039b8c88"&gt;nrfx_twim_xfer&lt;/a&gt;. This way, you can queue a lot of these transfers to happen periodically.&lt;/p&gt;
[quote user="simon1516"]- b_Battery_Pin was just for testing - setting a Pin high from the nrf52833 to high. Our custom board includes a battery management chip - this Pin high shall activate/enable the IC on the board.[/quote]
&lt;p&gt;That sounds great, thank you for clarifying this.&lt;/p&gt;
[quote user="simon1516"]- Yes, this is a good point. I have to do that. But making code better to read, doesn´t make fun :-) Please give me a few days for that.[/quote]
&lt;p&gt;He-he yes, I totally get what you are saying here!&lt;br /&gt;I am happy to hear that you might be taking this suggestion to heart :)&lt;/p&gt;
[quote user="simon1516"]- You´re right. But in each transfer I start a timer. But I need a second timer, to start the transfer. Because of that, I implemented two timers for this.[/quote]
&lt;p&gt;I am not sure that I see the need for a second timer here, as I have understood your setup.&lt;br /&gt;But, if it is working as intended and you are happy with the results then do not worry at all about my understanding of it.&lt;/p&gt;
[quote user="simon1516"]I try to implement the idle_state_handler the next days for better battery life. I haven´t done it yet, but I will give you a feedback here soon.[/quote]
&lt;p&gt;You already have the idle_state_handler implemented in your project - it came with the example you started out from. Just search for&amp;nbsp;&lt;em&gt;idle_state_handler&lt;/em&gt; in your main.c and you will see!&lt;br /&gt;All you need to do is call it, for example in the main loop.&lt;br /&gt;&lt;br /&gt;Looking forward to hearing your thoughts on using the &lt;em&gt;nrfx_twim_xfer&lt;/em&gt; flags I mentioned above!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268588?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 15:50:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cab896d-6a62-4b30-af66-d03aa3784615</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268465"]You can &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52833%2Fchapters%2Fcurrent_consumption%2Fdoc%2Ffrontpage.html"&gt;see the different power consumption scenarios here&lt;/a&gt;.[/quote]
&lt;p&gt;Thanks for this. So it make sense, setting CPU in sleep mode. I will try it :-)&lt;/p&gt;
&lt;p&gt;_____________________________________________________________&lt;/p&gt;
&lt;p&gt;My timers are working now, I get it! :-) In my case I call two times &amp;quot;nrfx_twim_xfer&amp;quot; in one read procedure. Because of that, I have declared two timers now. I had to split my read function in two parts (because a timer can just call one function after expiration).&lt;/p&gt;
&lt;p&gt;First timer: Repeatet, because I would like to send data in an special time intervall.&lt;/p&gt;
&lt;p&gt;Second timer: NOT repeatet; If First timer expired, second timer start&amp;acute;s - because of TWIM needs this time for processing well.&lt;/p&gt;
&lt;p&gt;In my case, first timer 1000ms,second timer 10ms. I try to reduce this the next days, we&amp;acute;ll see how much works.&lt;/p&gt;
&lt;p&gt;_____________________________________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268465"]Taking a quick look through your project I have the following questions:&lt;br /&gt;- what is the b_Battery_Pin define for?&lt;br /&gt;- all your &amp;quot;regX&amp;quot; variables should have proper names. I.e READ_XXX, or CTRL_XXX. You could also have a separate header file that defines all the possible commands for the sensor, which makes them easy to invoke. This increases readability and reduces that chance of mistyping a command / reading the wrong register.&lt;br /&gt;- your &amp;quot;my_timer_id&amp;quot; timer is set to be in REPEATED mode, I do not know if this is intentional? As I understood it you would just like to start the timer in between each transfer, to ensure that enough time passes for the device to be ready for the next transfer, was it not so? With the current REPEATED timer, triggering&amp;nbsp;&lt;em&gt;read_sensor_data&lt;/em&gt; you still rely on nrf_delay_ms in between your transfers.[/quote]
&lt;p&gt;- b_Battery_Pin was just for testing - setting a Pin high from the nrf52833 to high. Our custom board includes a battery management chip - this Pin high shall activate/enable the IC on the board.&lt;/p&gt;
&lt;p&gt;- Yes, this is a good point. I have to do that. But making code better to read, doesn&amp;acute;t make fun :-) Please give me a few days for that.&lt;/p&gt;
&lt;p&gt;- You&amp;acute;re right. But in each transfer I start a timer. But I need a second timer, to start the transfer. Because of that, I implemented two timers for this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;_____________________________________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I try to implement the idle_state_handler the next days for better battery life. I haven&amp;acute;t done it yet, but I will give you a feedback here soon.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you and kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268465?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 09:48:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2b92a51-e150-48b6-a1d7-9c6316c69e52</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]thanks for your support![/quote]
&lt;p&gt;No problem at all, I am happy to help!&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]No, it was just for testing the procedure while watching the timer expiration. In normal mode, we would like to process a TWIM with BLE transfer each 10ms, maybe 20ms. In your opinion, does it make sense to set the chip into sleep modus for this small time? If we expect, a data transfer needs about 2ms...then the chip could sleep for 8ms until the next transfer - a long time?[/quote]
&lt;p&gt;I would say 8 ms is quite a long time, especially if it is every 10 ms. That means you potentially have the CPU sleeping ( drawing significantly less power ) for 80% of the time ( unless you are doing something else in your application as well ). It is definitely better than having the CPU perform NOP cycles for the duration, with regards to power consumption.&lt;br /&gt;You can &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52833%2Fchapters%2Fcurrent_consumption%2Fdoc%2Ffrontpage.html"&gt;see the different power consumption scenarios here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you want to take it up another notch, you could look into using &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/radio_notif/radio_notification.html"&gt;Radio Notifications&lt;/a&gt;&amp;nbsp;to perform your TWIM transfers right before the next connection event. But, this is not required at this time. Lets first finish the work with the timer!&lt;/p&gt;
[quote user="simon1516"]What could be a good way to handle this? After each transfer, I can call &amp;quot;sleep_mode_enter()&amp;quot;. And then the system is off? Is it possible, to wake up with timer expiration as interrupt? Is there an easy example for this?[/quote]
&lt;p&gt;&amp;nbsp;Yes, the power manage module makes this quite easy. As you probably have seen in most of the SDK examples the only thing happening in the main while() loop is a function called &amp;quot;idle_state_handler&amp;quot;. If you look into this idle state handler, you will see that it is merely a call to the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrf__pwr__mgmt.html&amp;amp;anchor=ga4ed9cb21c98d64130c12eb8490821673"&gt;nrf_pwr_mgmt_run&lt;/a&gt;&amp;nbsp;function ( if there are no logs to process ). This function places the CPU in the &amp;quot;Wait for event&amp;quot; state. Once an event is generated, the CPU will handle it accordingly.&lt;br /&gt;So, it is both very easy to set up ( just use the provided power management module ), and easy to use - I highly recommend giving it a try! It will significantly increase the battery life of your device.&lt;/p&gt;
[quote user="simon1516"]Okay, but ignoration should be okay for me or not? But someting aborts in my application.[/quote]
&lt;p&gt;That the second timer_start is being ignored is fine, yes.&lt;br /&gt;For example, if your main loop keeps fetching data somewhere, and trying to process the data by sending it over TWIM. If your TWIM only happens at the end of the timer, and that timer is too long, then data will &amp;quot;build up&amp;quot; rapidly, since it is not being processed in time.&lt;br /&gt;&lt;br /&gt;When you say that something aborts in your application, are you then talking about the NRF_BUSY_ERROR returned from nrfx_twim_xfer?&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;Correct. It´s the function &amp;quot;nrfx_twim_xfer&amp;quot; again. The complete error message is:&lt;/p&gt;
&lt;p&gt;&amp;lt;error&amp;gt; app: ERROR 17 [NRF_ERROR_BUSY] at C:\Users\hp\Desktop\Firmware Entwicklung\nRF5SDK160098a08e2.zip\examples\ble_peripheral\ble_app_uart_with_twim v0.2\main.c:826&lt;br /&gt;PC at: 0x0003137B&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As we can see from the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__twim.html&amp;amp;anchor=gae53a1bebcd5961e1cd7a79e4039b8c88"&gt;nrfx_twim_xfer&lt;/a&gt;&amp;nbsp;documentation, NRF_ERROR_BUSY will be returned when the driver is not yet ready for a new transfer, such as if it is still working on the previous transfer and you attempt to start a new one.&lt;br /&gt;&lt;br /&gt;Taking a quick look through your project I have the following questions:&lt;br /&gt;- what is the b_Battery_Pin define for?&lt;br /&gt;- all your &amp;quot;regX&amp;quot; variables should have proper names. I.e READ_XXX, or CTRL_XXX. You could also have a separate header file that defines all the possible commands for the sensor, which makes them easy to invoke. This increases readability and reduces that chance of mistyping a command / reading the wrong register.&lt;br /&gt;- your &amp;quot;my_timer_id&amp;quot; timer is set to be in REPEATED mode, I do not know if this is intentional? As I understood it you would just like to start the timer in between each transfer, to ensure that enough time passes for the device to be ready for the next transfer, was it not so? With the current REPEATED timer, triggering&amp;nbsp;&lt;em&gt;read_sensor_data&lt;/em&gt; you still rely on nrf_delay_ms in between your transfers.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]Karl, thanks for you help![/quote]
&lt;p&gt;It is no problem at all, Simon!&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268367?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 15:25:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a155617-08ff-463c-841a-baa4b2eac2d9</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks for your support!&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268244"]So, what you would do is basically:[/quote]
&lt;p&gt;I&amp;acute;m doing it like this, so I think setting up the timer is correct.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268244"]&amp;nbsp;This is a 10,000 ms delay, i.e 10 s. Is this the intended delay?[/quote]
&lt;p&gt;No, it was just for testing the procedure while watching the timer expiration. In normal mode, we would like to process a TWIM with BLE transfer each 10ms, maybe 20ms. In your opinion, does it make sense to set the chip into sleep modus for this small time? If we expect, a data transfer needs about 2ms...then the chip could sleep for 8ms until the next transfer - a long time?&lt;/p&gt;
&lt;p&gt;What could be a good way to handle this? After each transfer, I can call &amp;quot;sleep_mode_enter()&amp;quot;. And then the system is off? Is it possible, to wake up with timer expiration as interrupt? Is there an easy example for this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268244"]documentation we see that this function call is ignored if the timer is already started.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Okay, but ignoration should be okay for me or not? But someting aborts in my application. But I&amp;acute;m with you, that the timer should just start at one time. Because of that, I moved this from my main loop to the initialization of my main application. So there the timer starts just one time. I&amp;acute;ve added the actual project file for you which includes main.c for analyzing this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268244"]Which function is returning this error code, nrfx_twim_xfer? And, what do you mean by &amp;quot;stuck&amp;quot;, does the device reset?[/quote]
&lt;p&gt;Correct. It&amp;acute;s the function &amp;quot;nrfx_twim_xfer&amp;quot; again. The complete error message is:&lt;/p&gt;
&lt;p&gt;&amp;lt;error&amp;gt; app: ERROR 17 [NRF_ERROR_BUSY] at C:\Users\hp\Desktop\Firmware Entwicklung\nRF5SDK160098a08e2.zip\examples\ble_peripheral\ble_app_uart_with_twim v0.2\main.c:826&lt;br /&gt;PC at: 0x0003137B&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Karl, thanks for you help! I think it&amp;acute;s time to add an actual project file (attached) for analyzing.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_uart_5F00_with_5F00_twim-v0.6.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_with_5F00_twim-v0.6.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268248?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 10:09:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f22b2b39-cdb4-4077-b160-2024dc8f7e31</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;If you would like a more fully-fledged tutorial on the app_timer, then &lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/application-timer-tutorial"&gt;I highly recommend taking a look at this one written by my colleague&lt;/a&gt;.&lt;br /&gt;The tutorial is a bit old, but the general approach and theory still holds true for the app_timer in the newest SDK.&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268244?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 09:47:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:381ee7fa-8e78-4f7b-9d3c-9f0f36e0e079</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]Thats it. After moving &amp;quot;APP_TIMER_DEF(my_timer_id);&amp;quot; to the top of main.c the compilation works fine.[/quote][quote user="simon1516"]But how can there be an ID (Integer Value) for my timer? I just give it the name my_timer_id. Do I have to give an ID at all? If I trying to do that, I get an error:[/quote]
&lt;p&gt;You do not need to give your timer an integer ID, no. The APP_TIMER_DEF creates an instance with that name. So, what you would do is basically:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;APP_TIMER_DEF(m_twi_timer);
..
err_code = app_timer_init();
..
err_code = app_timer_create(&amp;amp;m_twi_timer, APP_TIMER_MODE_SINGLE_SHOT, twi_timer_handler);
APP_ERROR_CHECK(err_code);
..
err_code = app_timer_start(m_twi_timer, TWI_TRANSMISSION_DELAY, NULL);
APP_ERROR_CHECK(err_code);
..
&lt;/pre&gt;&lt;br /&gt;If you would like to see the source of the compiler error you are getting here, go to the definition of APP_TIMER_DEF and see what argument it expects, vs. the integer &amp;quot;3&amp;quot; you provided.&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;Everything is set to &amp;quot;1&amp;quot;.&lt;/p&gt;
&lt;p&gt;NRFX_TIMER0_ENABLED to NRFX_TIMER4_ENABLED is set to 1.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for confirming this.&lt;/p&gt;
[quote user="simon1516"]APP_TIMER_TICKS(10000)[/quote]
&lt;p&gt;&amp;nbsp;This is a 10,000 ms delay, i.e 10 s. Is this the intended delay?&lt;/p&gt;
[quote user="simon1516"]the code stucks with NRF_BUSY error[/quote]
&lt;p&gt;Which function is returning this error code, nrfx_twim_xfer? And, what do you mean by &amp;quot;stuck&amp;quot;, does the device reset?&lt;/p&gt;
[quote user="simon1516"]Where is the difference? The only difference is, that in first example the function &amp;quot;read _sensor_data()&amp;quot;&amp;nbsp; is called automatically and in the second example the function &amp;quot;read _sensor_data()&amp;quot;&amp;nbsp; is called by expiration of the timer.[/quote]
&lt;p&gt;The difference is that the CPU is free to continue with other tasks in the meantime, while the timer is running. In your current setup, this means that the CPU will run for 10 seconds while the timer is still running. The question then becomes, what are you doing in these 10 seconds? If the code above is your entire main loop then the CPU will immediately enter the loop again, and try to start the timer again in the next loop iteration. From the&amp;nbsp;&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1" valign="bottom"&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__app__timer.html#gaa2e52b98d7c4030d5e283ddfe50c81c7"&gt;app_timer_start&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;documentation we see that this function call is ignored if the timer is already started.&lt;br /&gt;What you should instead do is therefore to either go to sleep, or perform some other task.&lt;br /&gt;Could you show the entire contents of your current main function?&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268117?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 17:17:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15df6d47-8c39-461c-a685-70b869240fc9</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am here again with new findings:&lt;/p&gt;
&lt;p&gt;__________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268088"]you will just need to move your APP_TIMER_DEF, and possibly also enable the timers in the sdk_config file[/quote]
&lt;p&gt;Thats it. After moving &amp;quot;APP_TIMER_DEF(my_timer_id);&amp;quot; to the top of main.c the compilation works fine. But how can there be an ID (Integer Value) for my timer? I just give it the name my_timer_id. Do I have to give an ID at all? If I trying to do that, I get an error:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/28700.1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;__________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/268088"]Could you also verify for me that&amp;nbsp;APP_TIMER_ENABLED, TIMER_ENABLED, and NRFX_TIMER_ENABLED is defined to 1 in the sdk_config? You will also need to have the particular timer instance ENABLE set to 1 ( seem to me like you are using timer instance 3 ).[/quote]
&lt;p&gt;Everything is set to &amp;quot;1&amp;quot;. &lt;/p&gt;
&lt;p&gt;NRFX_TIMER0_ENABLED to NRFX_TIMER4_ENABLED is set to 1.&lt;/p&gt;
&lt;p&gt;__________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I don&amp;acute;t define the &amp;quot;#define my_timer_id 3&amp;quot; the compiling works fine. Then the main loop is running. But after the expiration of the timer (#define TWIM_transmission_time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_TIMER_TICKS(10000)) the code stucks with NRF_BUSY error. It&amp;acute;s the same error like posted on 24. August 2020 7:54 p.m. (although I didn&amp;acute;t change anything on this function since then). So the behaviour is confusing a little bit.&lt;/p&gt;
&lt;p&gt;In my main loop is not much code.&lt;/p&gt;
&lt;p&gt;This works:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        nrf_delay_ms(20);
       // ret_code_t err_code = app_timer_start(my_timer_id, TWIM_transmission_time, NULL);
       // APP_ERROR_CHECK(err_code);
        read_sensor_data();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This doesn&amp;acute;t work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        nrf_delay_ms(20);
        ret_code_t err_code = app_timer_start(my_timer_id, TWIM_transmission_time, NULL);
        APP_ERROR_CHECK(err_code);
      //  read_sensor_data();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Where is the difference? The only difference is, that in first example the function &amp;quot;read _sensor_data()&amp;quot;&amp;nbsp; is called automatically and in the second example the function &amp;quot;read _sensor_data()&amp;quot;&amp;nbsp; is called by expiration of the timer. Because of that, I don&amp;acute;t think there is someting wrong with my function rather someting with the timer procedure...&lt;/p&gt;
&lt;p&gt;__________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So, I hope you see something that I don&amp;acute;t see, which I can fix :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268088?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 13:16:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36271497-a03f-4077-8755-983184c0bb25</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;br /&gt;&lt;br /&gt;You can see the necessary steps for using &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_timer.html"&gt;the application timer library in its documentation&lt;/a&gt;. It seems to me that you are close to making it work, you will just need to move your APP_TIMER_DEF, and possibly also enable the timers in the sdk_config file.&lt;/p&gt;
[quote user="simon1516"]But when I try to start the timer in my main function, then I get an error because &amp;quot;my_timer_id&amp;quot; is not declared in here:[/quote]
&lt;p&gt;You should move your APP_TIMER_DEF to the top of your file - right next to your #define&amp;#39;s.&lt;br /&gt;Could you also verify for me that&amp;nbsp;APP_TIMER_ENABLED, TIMER_ENABLED, and NRFX_TIMER_ENABLED is defined to 1 in the sdk_config? You will also need to have the particular timer instance ENABLE set to 1 ( seem to me like you are using timer instance 3 ).&lt;br /&gt;&lt;br /&gt;Hope this helps! :)&amp;nbsp;&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/268046?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 11:54:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b76918a-ff56-40cc-a7c5-5be267863a39</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;so now I just use my app_timer.h library but someting went wrong in my implementation.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For creating my timers I do the following:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for initializing the timer module.
 */
static void timers_init(void)
{

    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
    APP_TIMER_DEF(my_timer_id);
    err_code=app_timer_create(&amp;amp;my_timer_id,APP_TIMER_MODE_REPEATED, read_sensor_data);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But when I try to start the timer in my main function, then I get an error because &amp;quot;my_timer_id&amp;quot; is not declared in here:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6683.1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Could you explain me how to declare this const?&lt;/p&gt;
&lt;p&gt;If I say &amp;quot;#define my_timer_id 3&amp;quot; for example I get an error because of integer value is not possible here.&lt;/p&gt;
&lt;p&gt;Is there an example of using this app_timer? I didn&amp;acute;t find much using this app_timer :-/&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267964?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 07:33:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2ac4473-4f08-483e-906c-79ef9f96ef30</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]I am a Little bit confused.[/quote][quote user="simon1516"]Okay, but in this example it seems that there is a library &amp;quot;nrf_drv_timer.h&amp;quot; is used. But I already use &amp;quot;app_timer.h&amp;quot;. So I don´t think that I need both, or not? If I include additional&amp;nbsp;the &amp;quot;nrf_drv_timer.h&amp;quot; I get errors with my NRFX_Timer driver. I think in this example an other Driver is used, can this be?[/quote]
&lt;p&gt;I am sorry for any confusion I might have caused here, my mistake. I thought you were using the TIMER driver directly. If you are using the app_timer library, you will not need ot use the _TIMER_INSTANCE macro, but you will need to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__app__timer.html&amp;amp;anchor=gaf8712d5f21788ee57a694e9d3303d9ee"&gt;APP_TIMER_DEF&lt;/a&gt;&amp;nbsp;macro instead.&lt;br /&gt;If you are using the app_timer library, then you do not need to use the TIMER peripheral drivers directly - the app_timer library handles this for you.&lt;/p&gt;
[quote user="simon1516"]So do I have to include the new library (as shown in example) or can I just work with my app_timer library?[/quote]
&lt;p&gt;I am sorry about my confusion here, I thought you intended to use the TIMER driver, not the app_timer library. You may just use the app_timer library as you already are, no need to worry about the TIMER driver.&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267902?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 15:43:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fe0ee93-c7b1-4765-b28d-12f8ff33e6c5</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;I am a Little bit confused.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/267772"]If you are attempting to declare a timer instance, you will need to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__timer.html&amp;amp;anchor=gac8cf0e0a9612d6212a1b0bbedc1178be"&gt;_TIMER_INSTANCE&lt;/a&gt; macro. You can see this being done in line 72 of the SAADC example.[/quote]
&lt;p&gt;Okay, but in this example it seems that there is a library &amp;quot;nrf_drv_timer.h&amp;quot; is used. But I already use &amp;quot;app_timer.h&amp;quot;. So I don&amp;acute;t think that I need both, or not? If I include additional&amp;nbsp;the &amp;quot;nrf_drv_timer.h&amp;quot; I get errors with my NRFX_Timer driver. I think in this example an other Driver is used, can this be?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/267772"]If you are attempting to declare a timer instance, you will need to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__timer.html&amp;amp;anchor=gac8cf0e0a9612d6212a1b0bbedc1178be"&gt;_TIMER_INSTANCE&lt;/a&gt; macro. You can see this being done in line 72 of the SAADC example.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think for this I have to enable a few things in sdk_config, but I also use app_timer in my project for other Things.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So do I have to include the new library (as shown in example) or can I just work with my app_timer library?&lt;br /&gt;&lt;br /&gt;Thanks in Advance.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267772?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 08:43:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c87e6867-c60e-4a50-bf34-a30930ad8a60</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]I´m sorry for late reply.[/quote]
&lt;p&gt;Do not worry about this at all, it is no problem.&lt;/p&gt;
[quote user="simon1516"]No, not really. I don´t know for what this is for.[/quote]
&lt;p&gt;Using ASSERTs in your code is a very helpful tool when debugging, to make sure certain conditions are always fulfilled before executing code.&lt;br /&gt;&lt;a href="https://www.tutorialspoint.com/c_standard_library/c_macro_assert.htm"&gt;Here is a brief explanation&lt;/a&gt;. In this case, the ASSERT tells us that you did not provide the function with the required parameters, and it therefore can not continue.&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;Okay, I get it. I did it the same way like provided by the SAADC example. So now, every time the timer expires, my &amp;quot;sensor_data_read&amp;quot; function should be called. This is, what I would like to have.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Unfortunaly, it doesn´t work completely. I tried to start my timer in the main loop. While compiling I get a warning. Could you tell me, what is the reason for this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please tell me what the warning said - there is no way for me to see this from your included picture. What are you trying to do in your &lt;em&gt;static const my_timer_id = 3;&lt;/em&gt; line?&lt;br /&gt;If you are attempting to declare a timer instance, you will need to use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__timer.html&amp;amp;anchor=gac8cf0e0a9612d6212a1b0bbedc1178be"&gt;_TIMER_INSTANCE&lt;/a&gt; macro. You can see this being done in line 72 of the SAADC example.&lt;/p&gt;
[quote user="simon1516"]I commented out my &amp;quot;read_sensor_data&amp;quot; function because it is called automatically by expiration of the time (i hope so :-) ).[/quote]
&lt;p&gt;Cool, lets get this timer configuration out of the way, so we may see if it works!&lt;/p&gt;
[quote user="simon1516"]I think there is something wrong with the definition of my timer_id. As described in the&amp;nbsp;nordic InfoCenter, I declared this variable as a static. Do I have to pay attention to something other?[/quote]
&lt;p&gt;Yes, as I mentioned above you will need to use the INSTANCE macro. If you are uncertain about how something like this should be done, the fastest way to find out is to check a similar example and see how it is implemented there! :)&amp;nbsp;&lt;br /&gt;You will also need to make sure that the timer is enabled in your sdk_config file ( but since you did not receive a compiler error I think it already is ).&lt;br /&gt;Also here you may check the sdk_config file of the example, to see that it matches up on the particular functionality you are interested in using.&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267682?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 15:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b5ef197-0166-491f-af20-8c460e016aab</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;acute;m sorry for late reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/267234"]You may not provide NULL as the event_handler argument here, this is the reason why it ASSERTS. Are you familiar with using ASSERT?[/quote]
&lt;p&gt;No, not really. I don&amp;acute;t know for what this is for.&lt;/p&gt;
&lt;p&gt;_______________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/267234"]If you are unsure what you should provide as arguments to a function, or how to use a function, please see the functions API Refernce.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Okay, I get it. I did it the same way like provided by the SAADC example. So now, every time the timer expires, my &amp;quot;sensor_data_read&amp;quot; function should be called. This is, what I would like to have.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Unfortunaly, it doesn&amp;acute;t work completely. I tried to start my timer in the main loop. While compiling I get a warning. Could you tell me, what is the reason for this?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2warning.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6661.warning.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;I commented out my &amp;quot;read_sensor_data&amp;quot; function because it is called automatically by expiration of the time (i hope so :-) ).&lt;/p&gt;
&lt;p&gt;I think there is something wrong with the definition of my timer_id. As described in the&amp;nbsp;nordic InfoCenter, I declared this variable as a static. Do I have to pay attention to something other?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in Advance,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267234?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 12:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79e970eb-c455-416d-9fbe-da1661294e91</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;I debugged this and debug terminal shows me, that the error is here: app_timer2.c:559 --&amp;gt; (ASSERT(timeout_handler);)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I´m not really sure, what to insert in the &amp;quot;app_timer_create&amp;quot; for timeout_handler. I read that there is a function coming in, which is executed when the timer is expired. Could you please give me an example for this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You may not provide NULL as the event_handler argument here, this is the reason why it ASSERTS. Are you familiar with using ASSERT?&lt;br /&gt;If you are unsure what you should provide as arguments to a function, or how to use a function, please see the functions API Refernce.&lt;br /&gt;In this case, from the &lt;em&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__app__timer.html&amp;amp;anchor=ga5c31f03a2b9d4bf2a3cd629e6603e72e"&gt;app_timer_create&lt;/a&gt;&amp;nbsp;&lt;/em&gt;API Reference you can see that the third argument is the event_handler, which is the function to be called when the timer expires.&lt;br /&gt;In your case, you may therefore do a TWIM transfer for each expiration, for example.&lt;br /&gt;&lt;br /&gt;An example for an event_handler function is for instance the saadc_event_handler from the SAADC example.&lt;br /&gt;This is the function that is called every time the SAADC generates an event - which then is used to handle those events.&lt;br /&gt;So, when a DONE event is generated, the saadc_event_handler is the function that process the samples that are collected.&lt;br /&gt;Or, in your case, the timers event handler is the function you would like to call every time the timer expires.&lt;/p&gt;
[quote user="simon1516"]I´m doing this actually with one read with 14 bytes. This works fine :-)[/quote]
&lt;p&gt;Great, I am glad to hear that!&lt;br /&gt;In that case, adding a 500 us delay before the transfer should not increase your power consumption too much.&lt;/p&gt;
[quote user="simon1516"]I disabled deferred logging. Now there are no longer errors with this, so this works too :-)[/quote]
&lt;p&gt;Great! Just keep in mind that this adds some processing time to each NRF_LOG_* line in your function. So, if you have a function with a lot of debugging write-outs you it will take much longer to complete with DEFERRED LOGGING set to 0.&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;To this error again: Disabling the deffered logging solves that there are no longer the messages &amp;quot;Logs dropped ()&amp;quot;. But the main problem was not solved. I debugged again. And the code stops every time after exactly three minutes, because it is calling &amp;quot;static void sleep_mode_enter(void)&amp;quot;&amp;nbsp; and &amp;quot;err_code = sd_power_system_off();&amp;quot;&lt;/p&gt;
&lt;p&gt;Exactly three minutes, this is the time, the system is advertising for BLE devices! If I connect with nRF connect Mobile App to the nRF Chip, the TWIM doesn´t stop. The transmission is working until BLE connection is closed. So after advertising, the chip is calling the sleep mode was the explanation here.&lt;/p&gt;
&lt;p&gt;Like it works is okay, because TWIM just has to send data if a BLE connection is established. I just want to give you feedback for this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Good catch, I am happy to hear that you were able to identify the root of the behavior! This is exactly the time that your device is advertising.&lt;br /&gt;You may disable this feature, but it is a very good power-saving feature. What it does is make the device sleep if it has been without a connection for too long - conserving power by reducing RADIO ON time.&lt;br /&gt;In your situation, it sounds like you should keep this feature, if you only need to be awake when in a connection.&lt;br /&gt;Thank you for the feedback on this, I too am curious to hear about the problems resolve.&lt;/p&gt;
[quote user="simon1516"]Have a nice weekend, I hope we can solve my Timer issue together.[/quote]
&lt;p&gt;Thank you Simon, I did indeed have a nice weekend! I hope yours was as well.&lt;br /&gt;&lt;br /&gt;I think we are close to solving the Timer issue. I look forward to hearing if my comments above were helpful in resolving it!&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/267065?ContentTypeID=1</link><pubDate>Sat, 29 Aug 2020 13:24:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a0d1eed-ba6e-49b2-8ddb-ec6bb3a17b8c</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;_________________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266679"]Please let me know if anything should be unclear here, so I can provide more detail.&lt;br /&gt;What will you have your application doing in this time?[/quote]
&lt;p&gt;The Chip should go to sleep, when no transmission is required. So the Syntax should be:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;if Timer is expired&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;{&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;one TWIM procedure&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;restart Timer&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;}&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;acute;ve tried to implement this but unfortunaly I get an error if I try to create a new timer. I do the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    APP_TIMER_DEF(my_timer_id); // define new timer
    err_code=app_timer_create(&amp;amp;my_timer_id,APP_TIMER_MODE_REPEATED, NULL); //Create this timer, Time mode repeated because timer should restart every time it is expired. I&amp;#180;m not sure what to insert for &amp;quot;NULL&amp;quot;
    APP_ERROR_CHECK(err_code); // Check if Timer was created successfully&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I debugged this and debug terminal shows me, that the error is here: app_timer2.c:559 --&amp;gt; (ASSERT(timeout_handler);)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;acute;m not really sure, what to insert in the &amp;quot;app_timer_create&amp;quot; for timeout_handler. I read that there is a function coming in, which is executed when the timer is expired. Could you please give me an example for this?&lt;/p&gt;
&lt;p&gt;________________________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266679"]Are you doing the 14 byte read as a single read, or 7 x 2-byte reads?[/quote]
&lt;p&gt;I&amp;acute;m doing this actually with one read with 14 bytes. This works fine :-)&lt;/p&gt;
&lt;p&gt;_______________________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266679"]Yes, attempt to disabled deferred logging as I recommend above, and let me know if this resolves the issue.[/quote]
&lt;p&gt;I disabled deferred logging. Now there are no longer errors with this, so this works too :-)&lt;/p&gt;
&lt;p&gt;_______________________________________________________________&lt;/p&gt;
[quote userid="88554" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266583"]In debug terminal I just can see the message &amp;quot;Logs dropped ()&amp;quot; as described above. There is no line number printed out to see where the error happened. Here a screenshot from the error:[/quote]
&lt;p&gt;To this error again: Disabling the deffered logging solves that there are no longer the messages &amp;quot;Logs dropped ()&amp;quot;. But the main problem was not solved. I debugged again. And the code stops every time after exactly three minutes, because it is calling &amp;quot;static void sleep_mode_enter(void)&amp;quot;&amp;nbsp; and &amp;quot;err_code = sd_power_system_off();&amp;quot;&lt;/p&gt;
&lt;p&gt;Exactly three minutes, this is the time, the system is advertising for BLE devices! If I connect with nRF connect Mobile App to the nRF Chip, the TWIM doesn&amp;acute;t stop. The transmission is working until BLE connection is closed. So after advertising, the chip is calling the sleep mode was the explanation here.&lt;/p&gt;
&lt;p&gt;Like it works is okay, because TWIM just has to send data if a BLE connection is established. I just want to give you feedback for this.&lt;/p&gt;
&lt;p&gt;______________________________________________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have a nice weekend, I hope we can solve my Timer issue together.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/266679?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 09:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0efc256f-82d3-48ec-b1c7-3ad831fe48c2</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Simon,&lt;/p&gt;
[quote user="simon1516"]BEFORE and AFTER my read process a delay of 500us. If I reduce the number of us more, the read process didn´t work correctly (I checked this with printing the values by uart and I could see that the transmission didn´t work with lower timing). Could you maybe give me a syntax for replacing this with app_timer ?[/quote]
&lt;p&gt;500 us does not sound too bad in this case ( depending on your if you are reading 14 bytes every transfer, or only two, see my question below ).&lt;br /&gt;You can read about the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Flib_timer.html&amp;amp;anchor=lib_timer_usage"&gt;app timer&amp;#39;s usage and syntax in the library documentation&lt;/a&gt;, or in the Timer example or see its usage demonstrated in the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/nrf_dev_timer_example.html"&gt;Timer example from the SDK&lt;/a&gt;. Please let me know if anything should be unclear here, so I can provide more detail.&lt;br /&gt;What will you have your application doing in this time?&lt;br /&gt;I guess the simplest case for power consumption would be to start the timer, then immediately go to sleep ( for example using &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s140.api.v7.0.1%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga11d88d38ac99fb72cde74c9385d36433"&gt;sd_app_evt_wait()&lt;/a&gt;&amp;nbsp;or similar ).&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;- I would like to read 14 bytes each transfer (&lt;a href="https://invensense.tdk.com/wp-content/uploads/2016/06/DS-000189-ICM-20948-v1.3.pdf"&gt;https://invensense.tdk.com/wp-content/uploads/2016/06/DS-000189-ICM-20948-v1.3.pdf&lt;/a&gt; chapteer 7.1, register &amp;quot;2D&amp;quot; to &amp;quot;3A&amp;quot;). Accelerometer-Value X, Y, Z (each 2 bytes), Gyroscope-Value X, Y, Z (each 2 bytes) and Temperatur-Value (2 bytes). So in sum 14 bytes.&lt;/p&gt;
&lt;p&gt;- I would like to read the 14 bytes every 10ms. This frequency should be changeable.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for clarifying on this.&lt;br /&gt;Are you doing the 14 byte read as a single read, or 7 x 2-byte reads?&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;NRF_LOG_DEFERRED is &amp;quot;1&amp;quot; and NRF_LOG_BUFSIZE is &amp;quot;1024&amp;quot;.&lt;/p&gt;
&lt;p&gt;Do I have the option to deactivate this log-deferring? I am not really sure if I need it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Deferred logging means that the logs are put into a buffer when you call NRF_LOG_INFO(), but not actually processed ( since processing it at that particular time in the code might be unwanted ). The logs therefore needs to be processed from the buffer, which you can do using&amp;nbsp;NRF_LOG_PROCESS(). This is ideally done when the processor is free from other tasks. A good implementation of this is shown in many of our examples, for instance the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/ble_sdk_app_proximity.html"&gt;BLE Proximity Peripheral example&lt;/a&gt;, in which the NRF_LOG_PROCESS is called when the CPU is idling. If there are no more logs to process, the application goes to sleep.&lt;br /&gt;You could set NRF_LOG_DEFERRED to 0 to surpress this. It might make some of your functions take longer to complete, since logs are processed as they are called, but I would think it should make no difference for your application here.&lt;/p&gt;
[quote user="simon1516"]In debug terminal I just can see the message &amp;quot;Logs dropped ()&amp;quot; as described above. There is no line number printed out to see where the error happened. Here a screenshot from the error:[/quote]
&lt;p&gt;&amp;nbsp;Yes, attempt to disabled deferred logging as I recommend above, and let me know if this resolves the issue.&lt;/p&gt;
[quote user="simon1516"]Thank you for helping us with our product development :-)[/quote]
&lt;p&gt;Absolutely, it is no problem at all Simon - I am happy to help! :)&amp;nbsp;&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/266583?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 17:31:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b39eee9e-5675-4a41-8053-d7b7d06c93c3</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;here I am again with new findings.&lt;/p&gt;
&lt;p&gt;_______________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266408"]However, could you first try to see what the required delay is, by using nrf_delay?&lt;br /&gt;It might be that your TWI slave requires some delay between transfer.[/quote]
&lt;p&gt;It seems so. I measured a few write/read procedures with different timing parameters. The result:&lt;/p&gt;
&lt;p&gt;I have to implement at least the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; nrf_delay_us(500);
 
    /* Read */
   err_code = nrfx_twim_xfer(&amp;amp;m_twim, &amp;amp;lm75b_reading, NULL);
   APP_ERROR_CHECK(err_code);

 nrf_delay_us(500);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;BEFORE and AFTER my read process a delay of 500us. If I reduce the number of us more, the read process didn&amp;acute;t work correctly (I checked this with printing the values by uart and I could see that the transmission didn&amp;acute;t work with lower timing). Could you maybe give me a syntax for replacing this with app_timer ?&lt;/p&gt;
&lt;p&gt;___________________________________________________________&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266408"]Could you detail for me what transfers you will make - how frequent are they, and how many bytes are in each transfer?[/quote]
&lt;p&gt;- I would like to read 14 bytes each transfer (&lt;a href="https://invensense.tdk.com/wp-content/uploads/2016/06/DS-000189-ICM-20948-v1.3.pdf"&gt;https://invensense.tdk.com/wp-content/uploads/2016/06/DS-000189-ICM-20948-v1.3.pdf&lt;/a&gt; chapteer 7.1, register &amp;quot;2D&amp;quot; to &amp;quot;3A&amp;quot;). Accelerometer-Value X, Y, Z (each 2 bytes), Gyroscope-Value X, Y, Z (each 2 bytes) and Temperatur-Value (2 bytes). So in sum 14 bytes.&lt;/p&gt;
&lt;p&gt;- I would like to read the 14 bytes every 10ms. This frequency should be changeable.&lt;/p&gt;
&lt;p&gt;____________________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266408"]Yes, please check your sdk_config file, to see if the&amp;nbsp;NRF_LOG_DEFERRED is defined as 1 or 0, and if it is 1, what is then the size of&amp;nbsp;NRF_LOG_BUFSIZE?&amp;nbsp;[/quote]
&lt;p&gt;NRF_LOG_DEFERRED is &amp;quot;1&amp;quot; and NRF_LOG_BUFSIZE is &amp;quot;1024&amp;quot;.&lt;/p&gt;
&lt;p&gt;Do I have the option to deactivate this log-deferring? I am not really sure if I need it.&lt;/p&gt;
&lt;p&gt;_______________________________________________________________&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266210"]Where does the application stop after three minutes, is it a particular place in the code?[/quote]
&lt;p&gt;In debug terminal I just can see the message &amp;quot;Logs dropped ()&amp;quot; as described above. There is no line number printed out to see where the error happened. Here a screenshot from the error:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2055.1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for helping us with our product development :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/266408?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 09:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c864114-7200-42ad-938f-094ef18414cb</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Simon,&lt;/p&gt;
&lt;p&gt;[quote user="simon1516"][/quote]&lt;/p&gt;
&lt;p&gt;Could you guide me how to use such a timer? I defined &amp;quot;#define TWIM_transmission_time APP_TIMER_TICKS(10)&amp;nbsp;&amp;quot; to get a timer with 10ms delay time. So now, I would like to use this timer in my &amp;quot;twim_handler&amp;quot;. Nothing should happen, if the timer isn´t expired. The timer should restart, if it is expired and an twim event was done. Could you give me a small Syntax for this?&lt;/p&gt;
&lt;p&gt;I have already included &amp;quot;app_timer.h&amp;quot;, so I think it would make sense to use this.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Yes, it would be easiest to use the app_timer to create and manage the timer.&lt;br /&gt;However, could you first try to see what the required delay is, by using nrf_delay?&lt;br /&gt;It might be that your TWI slave requires some delay between transfer.&lt;br /&gt;&lt;br /&gt;It is slightly more work to implement the solution without wasted CPU cycles. Could you detail for me what transfers you will make - how frequent are they, and how many bytes are in each transfer?&lt;br /&gt;If you are only doing pairs of two and two bytes ( R/W commands ) then you could perhaps solve this by using the DESC_TXTX and DESC_TXRX, for example. It would mean a lot less work to use the already implemented features of the TWIM driver, so lets look at that first if possible, or depending on your specification we might use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrfx__twim.html#gaf2f189655c4fee0ed50936a4290671cc"&gt;NRFX_TWIM_FLAG_HOLD_XFER&lt;/a&gt;&amp;nbsp;feature instead.&lt;/p&gt;
[quote user="simon1516"]Could you tell me, how to get this Information?[/quote]
&lt;p&gt;Yes, please check your sdk_config file, to see if the&amp;nbsp;NRF_LOG_DEFERRED is defined as 1 or 0, and if it is 1, what is then the size of&amp;nbsp;NRF_LOG_BUFSIZE?&amp;nbsp;&lt;/p&gt;
[quote user="simon1516"]Here I think I have to debug again (because debugging is working now :-) ). I will try this and give you a short Feedback the next days![/quote]
&lt;p&gt;Great, that sounds like a good plan - I look forward to hearing your findings!&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: undefined reference twi error</title><link>https://devzone.nordicsemi.com/thread/266310?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 16:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c00e826-8b3c-4aca-9b51-f3e4aa6998f7</guid><dc:creator>simon1516</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266210"]For example, the flag you are currently clearing in the event handler, perhaps that instead should start a timer that expires after a certain time, which allows the next transfer to proceed?&lt;br /&gt;This will free up the CPU to do other tasks ( or sleep ) for the transfer wait period.[/quote]
&lt;p&gt;Could you guide me how to use such a timer? I defined &amp;quot;#define TWIM_transmission_time APP_TIMER_TICKS(10)&amp;nbsp;&amp;quot; to get a timer with 10ms delay time. So now, I would like to use this timer in my &amp;quot;twim_handler&amp;quot;. Nothing should happen, if the timer isn&amp;acute;t expired. The timer should restart, if it is expired and an twim event was done. Could you give me a small Syntax for this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have already included &amp;quot;app_timer.h&amp;quot;, so I think it would make sense to use this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266210"]Are you using deferred logging?[/quote]
&lt;p&gt;Could you tell me, how to get this Information?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/63114/undefined-reference-twi-error/266210"]What do you mean when you say &amp;quot;didnt work&amp;quot;?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here I think I have to debug again (because debugging is working now :-) ). I will try this and give you a short Feedback the next days!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>