<?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>GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85953/gpio-to-1-7v-after-enabling-twi</link><description>Hi :) , 
 I&amp;#39;m using TWI to connect a sensor that i supply with an LDO regulator. 
 
 This LDO has an enable pin controlled by P0_23. Driving current is max 1uA so i configured my GPIO in S0S1 mode. 
 When i start my application i can control properly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 20 Mar 2022 18:48:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85953/gpio-to-1-7v-after-enabling-twi" /><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358972?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2022 18:48:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcfd4804-ac72-460b-a52a-8b7b2b07bab2</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;These are the figures I calculated, can&amp;#39;t guarantee them but they are based on using the same algorithm used for the UART baud rate generator as the hardware peripherals are shared.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// --------Calculated-------------------  --------Documentation--------
// Required Register      Actual   Error  Register    Required   Actual
// ======== =========== ======== =======  =========== ======== ========
//  100000, 0x0199A000,  100006, +0.006%  0x01980000,  100000,  100000,
//  200000, 0x03333000,  199996, -0.002%           -,       -,       -,
//  250000, 0x04000000,  250000, +0.000%  0x04000000,  250000,  250000,
//  400000, 0x06666000,  399993, -0.001%  0x06400000,  400000,  400000,&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the formula I used:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define MAGIC_SCALE_FACTOR 32
#define MAGIC_SYSTEM_CLOCK 16000000ULL; // Typically 16MHz for Uart

// Notes on calculation:
uint32_t CalculatedRegisterValue;
uint32_t ActualBaudRate = 250000UL;
   CalculatedRegisterValue = (uint32_t)((((uint64_t)RequiredBaudRate &amp;lt;&amp;lt; MagicScaler) / SystemClock) + 0x800) &amp;amp; 0xFFFFF000;
   ActualBaudRate = (uint32_t)(((uint64_t)CalculatedRegisterValue * SystemClock) &amp;gt;&amp;gt; MagicScaler);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The mask register may be different for the TWI/I2C with fewer active bits, haven&amp;#39;t verified this.&lt;/p&gt;
&lt;p&gt;On the &amp;#39;scope capture try checking with the sensor disconnected to ensure there are no external interactions which can affect the displayed waveform (eg clock-stretching etc).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358971?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2022 16:43:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21de8084-a40e-46f3-a783-ac308bea72cb</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp; a lot for your help ;) in fct i would like 400khz but i only get 200khz.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know why this is so complicated , it should be simpler and much less confusing !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358970?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2022 16:38:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e86c8044-f743-435d-87d2-0fdb2c3557ac</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The example for sdk_config.h has this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	Line 148: #define NRFX_TWIM_ENABLED 1
	Line 265: #define NRFX_TWI_ENABLED 1
	Line 611: #define TWI_ENABLED 1
	Line 657: #define TWI0_ENABLED 1
	Line 671: #define TWI1_ENABLED 1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Very confusing, don&amp;#39;t remember just how these are used as I use bare metal drivers. Perhaps search for each of these to see how they are used.&lt;/p&gt;
&lt;p&gt;The frequency value you are using is not correct for 200kHz, if I get time I&amp;#39;ll have a look at finding the correct value&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358966?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2022 12:25:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9389ae5-8123-4d9b-9191-7b014c43a8dc</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi realised also that it is the twim module that is used and not the twi, so i found another place where pull up are defined&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647773703728v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So i disable it by using&amp;nbsp;NRF_GPIO_PIN_NOPULL and now i clearly see the lines staying low without external resistor, so that was the line to modify.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To confirm that i see in sdk_config :&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647774064491v2.png" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647774094446v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So it seems that TWIM is enabled but not TWIM0 and 1&lt;/p&gt;
&lt;p&gt;And TWI is also enable , not TWI0 but TWI1 yes.&lt;/p&gt;
&lt;p&gt;Frequency is set to 100khz on twi and twim , so the half of what i have on scope.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;i don&amp;#39;t know how is managed twi vs twim because her eand ther ein the code i can see if twim is supported then, take this instead of twi module&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358963?ContentTypeID=1</link><pubDate>Sun, 20 Mar 2022 10:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c98828f4-3515-4c0f-97ca-d7cd61678f41</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;Hi :)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I removed my external pull up resitor and now i can see twi lines going to vcc of the nrf52. But i&amp;#39;m surprised of several things:&lt;/p&gt;
&lt;p&gt;My sensors i working well, i&amp;#39;m just not satisfied with the freqency and signal shape, and the pull up configuration&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) here the content of the files nrf_drv_twi.c where&amp;nbsp;Pull up are enable, but when i disable it, i see no difference on my physical lines, as if this config stuff were not used.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647772314569v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2) i asked for 400khz but i only get 200khz on my scope, but it is ok in register.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647772816531v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647773528351v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;3) the shape of the rising edge is really slow.&amp;nbsp; on top it is with internal pull up resistor, i guess. Because as said earlier, when i disable it i get the same signal !&lt;/p&gt;
&lt;p&gt;Here is the signal with my external 4k7pull up resistors, and pull up resistors diable in the software...&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647772947104v3.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358931?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2022 18:40:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4afe6eb4-26ff-4f35-98ee-f8313abb82ae</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;&amp;quot;&lt;span&gt;&lt;em&gt;my LDO regulator voltage output goes to 1.7V&lt;/em&gt;&amp;quot;. Does this happen only when P0.23 = 0, ie the LDO is off? If so it is possible any output pins connected from the nRF52 to the sensor will power up the sensor through the sensor&amp;#39;s internal schottky protection diodes and back-drive the LDO thus raising the LDO voltage from 0 to (say) 1.7 volts. If the only 2 pins connected to the sensor are SCL and SDAZ check the configuration after the init; if that is set to S0D1 or H0D1 with &lt;em&gt;both&lt;/em&gt; pull-ups disabled then that would be unexpected behavior. Either pull-up enabled (or an external pull-up to nRF52 VDD) will phantom power the sensor and hence there will be a voltage on the LDO even when off.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO to 1.7V after enabling TWI</title><link>https://devzone.nordicsemi.com/thread/358926?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2022 16:56:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4671af15-5bbf-4327-a6e2-06b0b703a53f</guid><dc:creator>Olfox</dc:creator><description>&lt;p&gt;&lt;span&gt;I&amp;#39;m also using externals pull up cause the 13kohm internal resistors are a bit weak. I disabled the internal resistor. I wonder if it is not the fact that when i init twi module the two lines are set to vbat and if the supply is not on, some electronic of the LDO pull the line to 1.7V. Solution will be may be to pull up to vcc of the nrf and not to the vdd of the ldo.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>