<?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>Create a bi-directional pin using PPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33398/create-a-bi-directional-pin-using-ppi</link><description>I&amp;#39;m working on a driver for a sensor which uses a proprietary one-wire interface. To get data out of the device, we do the following: 1) switch the pin to output 2) 1 us low 3) 1 us high 4) Switch the pin to input 5) wait 8 us for the signal to settle</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Apr 2018 19:22:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33398/create-a-bi-directional-pin-using-ppi" /><item><title>RE: Create a bi-directional pin using PPI</title><link>https://devzone.nordicsemi.com/thread/128538?ContentTypeID=1</link><pubDate>Mon, 16 Apr 2018 19:22:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d102fe87-0b99-467d-87cd-0c0ab299940b</guid><dc:creator>dbuijsma</dc:creator><description>&lt;p&gt;No problem! Thanks for the fast response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The second reason for using just the PPI, which I should have mentioned,&amp;nbsp;is to be able to guarantee the PIR waveform timing. The issue with using the&amp;nbsp;CPU for any aspect of the read-out process is that the Softdevice might&amp;nbsp;interfere and we end up not making the timing specs for the PIR sensor (some parts of the waveform need to be timed within&amp;nbsp; &amp;lt; 2us). With the Softdevice doing its own thing, this is almost guaranteed to be an issue.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve got the waveform generation covered like you mention with timers and CC-events/GPIOTE tasks. The plan was to clock the data into the SPI peripheral (slave mode). If I&amp;#39;m going to use IRQs, that&amp;#39;s&amp;nbsp;no longer&amp;nbsp;necessary. I just need to be able to generate IRQs timely&amp;nbsp;(without&amp;nbsp;&lt;span&gt;Softdevice&lt;/span&gt; shenanigans).&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t mind, could&amp;nbsp;you look at some ideas to get around the issue (which don&amp;#39;t involve changing the HW) to make sure I am not missing potentially better options?&lt;/p&gt;
&lt;p&gt;1)&amp;nbsp;Make sure the Softdevice is not used or even disabled while we&amp;#39;re sampling from the sensor. I noticed this thread which suggests this is possible:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/24426/disabling-s132-softdevice-when-running-freertos"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/24426/disabling-s132-softdevice-when-running-freertos&lt;/a&gt;. However, this option will require some major changes in the current application-level code which is relying on the Softdevice to always be enabled.&lt;/p&gt;
&lt;p&gt;2) A little ugly, but...change the vector table so we have a hook into this and can re-direct the SD -IRQ (level 0) handler and forward this from our&amp;nbsp;&amp;nbsp;super-short &amp;quot;change-pin-direction&amp;quot; handler.&lt;/p&gt;
&lt;p&gt;3) Even uglier: Use the PPI/MWU + some other peripheral with EasyDMA to generate&amp;nbsp;a NMI which we can then use as our IRQ handler to change the pin direction.&lt;/p&gt;
&lt;p&gt;4) Blasphemy...but: In theory I could edit the Softdevice binary to change the IRQ (level 0) to a lower level such that my application. I am guessing that this is a no-go (Nordic user agreement violation?), but&amp;nbsp;wanted to mention it nonetheless in case someone has done it before.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now ideally there would have been a task in the GPIOTE peripheral to&amp;nbsp;set direction on a pin. This would at least for my case really be a useful feature for the next nRF52 SoC. Just say&amp;#39;in!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Dirk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Create a bi-directional pin using PPI</title><link>https://devzone.nordicsemi.com/thread/128446?ContentTypeID=1</link><pubDate>Mon, 16 Apr 2018 11:41:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdc84a6b-0d54-49ae-8b25-2b5400937c8e</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey Dirk,&lt;/p&gt;
&lt;p&gt;I believe I&amp;#39;ve made a mistake.&lt;/p&gt;
&lt;p&gt;You cannot disable a GPIOTE pin via PPI once it&amp;#39;s configured as an output, you can only disconnect it from the PPI system. It will drive the input pin to whatever voltage of its last state.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This means that you will need to reconfigure the output pins direction via CPU. The good news is that you will only need one pin instead of two.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should use a TIMER to control the output pin. Create a one-shot TIMER with COMPARE0 event connected to the output pins GPIOTE toggle task (initial GPIO state high), COMPARE1 event connected to the output pins GPIOTE toggle task, and COMPARE2 event to fire a CPU interrupt.&lt;/p&gt;
&lt;p&gt;COMPARE0 can be set to whatever time you want, it starts the sequence of events by pulling the output pin low. COMPARE1 needs to be set 1µs after COMPARE0 and COMPARE2 needs to be set 1µs after COMPARE1.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>