<?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>Timers and activity on positive pulse</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79183/timers-and-activity-on-positive-pulse</link><description>I am trying to set a timer pulse at 500kHz and on every high pulse i want to do a read on another pin. 
 
 I have an IC HX711, that has a 24bit output MSB. every positive cycle it changes to the next bit. 
 If i were to bit bang it would be like this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Sep 2021 11:21:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79183/timers-and-activity-on-positive-pulse" /><item><title>RE: Timers and activity on positive pulse</title><link>https://devzone.nordicsemi.com/thread/327769?ContentTypeID=1</link><pubDate>Thu, 02 Sep 2021 11:21:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc5d6a4d-ca15-4c05-a95e-a327905186c8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;There are a couple of ways to do this, and the one that is conceptually the simplest might be to use a timer to schedule the clock signal toggle and the pin readout, and use the PPI and GPIOTE to connect the timer to the clock pin directly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially you set up one CC register in the timer to schedule when the clock pin should go low, one CC register to schedule when it goes high, and a third CC register to schedule when the pin should be read. By enabling a shortcut from the last CC even to the clear task you can have the timer cleared automatically, in order to run multiple loops of this sequence.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The easy way to read the pin is to enable the interrupt handler for the timer, and enable the interrupt for the third CC register. Then you can simply read out the state of the pin in the interrupt. By adjusting the value of the CC register you can adjust when the pin is sampled relative to the clock output.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The drawback of this method is if you have higher priority interrupts in the system, as they might delay the reading out of the pin and give you an incorrect value.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The 100% foolproof way of doing this is to use the SAADC module to sample the pin, as you can connect the SAADC to the CC event directly through the PPI.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you will not be affected by high priority interrupts, since everything will run in the background based on the TIMER, PPI, GPIOTE and SAADC peripherals, but you will need to do some conversion in order to change 10-bit analog ADC values into&amp;nbsp;bits.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>