<?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>SWD interface changing phase from send to receive?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9141/swd-interface-changing-phase-from-send-to-receive</link><description>Is there a more thorough documentation of the SWD interface as implemented on the nRF chips? 
 I&amp;#39;m seeing something I regard as strange when I look at things on a scope. 
 In order to make my nRF51822 accept a command (IDCODE for instance) I have to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Sep 2015 09:14:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9141/swd-interface-changing-phase-from-send-to-receive" /><item><title>RE: SWD interface changing phase from send to receive?</title><link>https://devzone.nordicsemi.com/thread/33692?ContentTypeID=1</link><pubDate>Fri, 11 Sep 2015 09:14:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ae1ca59-a41a-4b5c-a929-d9da98b380c7</guid><dc:creator>Andrew Lentvorski</dc:creator><description>&lt;p&gt;Upvoted.  Thanks for an actual reference with edges in it.  You&amp;#39;d think ARM would put this in their other documentation somewhere.&lt;/p&gt;
&lt;p&gt;Yeah, the turnaround looks stupid from an outside point of view, but after thinking about it for a while it makes sense when you consider that that target has no running clock other than what is being provided by the debug probe.&lt;/p&gt;
&lt;p&gt;On target receive, the target has to 1) Sample on clock rising edge and then 2) do something with that sample on the clock falling edge.  On target transmit, the target has to 1) Prepare something on clock falling edge and then 2) put that something on the line on the clock rising edge.&lt;/p&gt;
&lt;p&gt;And that&amp;#39;s why the turnaround cycles are where they are.  That way the system has an extra clock cycle to do something when it has to.&lt;/p&gt;
&lt;p&gt;Sigh.  All this effort to avoid using 3 signals (SCK, SDO, SDI) instead of two (SCK, SDO/SDI) when most people would rather have the ability to use a dedicated SWO-like signal anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SWD interface changing phase from send to receive?</title><link>https://devzone.nordicsemi.com/thread/33691?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2015 09:46:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc425747-d4f7-4037-bec6-9a0889d1c2ce</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Having researched this properly and read the documentation again, I&amp;#39;ll move it from comment to answer.&lt;/p&gt;
&lt;p&gt;The debug unit is a standard ARM one and all the documentation for it is the standard ARM documentation.&lt;/p&gt;
&lt;p&gt;The description of the SWD wire protocol is at &lt;a href="http://infocenter.arm.com/help/topic/com.arm.doc.dui0499j/DUI0499J_arm_ds5_arm_dstream_reference_guide.pdf"&gt;infocenter.arm.com/.../DUI0499J_arm_ds5_arm_dstream_reference_guide.pdf&lt;/a&gt; section 2.1.2 where it has a useful figure and a table.&lt;/p&gt;
&lt;p&gt;The table confirms what you see. Both the probe and the target read data on a rising SWDCLK, however the target writes data on a rising SWDCLK but the probe writes data on a falling SWDCLK.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t instantly see how the probe could read and the target write on a rising CLK, wouldn&amp;#39;t the data be changing, however it makes sense when you realise that the probe is generating the clock, and the target is detecting the clock.&lt;/p&gt;
&lt;p&gt;So when the probe reads, it does so when the CLK line is low, just before it sets it high, ie just before it generates the rising edge. So as soon as the target detects the rising edge, it can write new data, the probe has already read it, guaranteed. However when the target has data to read it also does it on a rising edge, but it needs to detect the edge, hence the probe has to raise the CLK to high and then leave the data valid for long enough for the target to read it, it gives the target 1/2 a cycle, while the CLK is high and after it puts it back low, then it writes the next bit of data while it&amp;#39;s low, then repeats the cycle.&lt;/p&gt;
&lt;p&gt;This gives the target one complete cycle to write new data and a 1/2 cycle to detect the clock rising edge and read data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>