<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Maple Logic Analyzer?</title>
		<link>http://forums.leaflabs.com/topic.php?id=74071</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:04:59 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=74071" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104827</link>
			<pubDate>Sun, 27 Oct 2013 09:35:50 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104827@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Magnus - Great work!&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;I can reliably, with no noticable jitter when sampling a 1kHz signal, sample from DMA at 6MHz, this is 1/12 of 72MHz, 8MHz sampling at 1/9 of 72MHz cannot quite keep up.&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;That is a very interesting result. The STM32F103 documentation is vague about throughput, so I'd assumed there'd be a way to get DMA to do about 1/8th of clock (as you say, about 4 (visible) operations, and a 50:50 share of the buses and memory with the CPU), but never measured. So thanks for the work, and thanks for sharing results.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mlundinse on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104826</link>
			<pubDate>Sat, 26 Oct 2013 14:18:37 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">104826@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I will clean up my work and post it soon, but I would like to worka bit on the triggering code first. Without a trigger I can reliably, with no noticable jitter when sampling a 1kHz signal, sample from DMA at 6MHz, this is 1/12 of 72MHz, 8MHz sampling at 1/9 of 72MHz cannot quite keep up.&#60;/p&#62;
&#60;p&#62;(each DMA request makes one peripherial register access, one memory access, decrements the DMA counter and increments the memory access pointer and AFAIK the processor is guaranteed 50% of bus bandwith leaving less than 50% to DMA)&#60;/p&#62;
&#60;p&#62;I am not shure it is meaningful to try and push this much further, but it is an interesting programming task and a way to learn the precice performance of the 103 chip.&#60;/p&#62;
&#60;p&#62;For a quick and cheap logic analyzer its not bad, also a starting point for more developed solution.&#60;/p&#62;
&#60;p&#62;/Magnus
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104825</link>
			<pubDate>Sat, 26 Oct 2013 13:03:22 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104825@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mlundinse - &#60;em&#62;&#34;The contention for DMA should be minimal since other activities can be silienced, we are thinking of a Maple devted to this task.&#34;&#60;/em&#62;&#60;br /&#62;
Good comment.  I agree; it is very reasonable to assume a Maple is devoted to the task.&#60;br /&#62;
The goal is to use the already-written &#60;a href=&#34;http://www.lxtreme.nl/ols&#34;&#62;&#34;Logic Sniffer&#34;&#60;/a&#62; host UI (identified by samtal) 'as is'.&#60;br /&#62;
AFAICT &#60;a href=&#34;http://www.lxtreme.nl/ols&#34;&#62;&#34;Logic Sniffer&#34;&#60;/a&#62; doesn't currently offer any features which would affect that assumption.&#60;/p&#62;
&#60;p&#62;(It would be even better to, for example, be able to use the Maple to generate test signals, e.g. SPI, I2C, etc. That might make the Maple software even more interesting and useful than the Arduino starting point. The &#60;a href=&#34;http://www.lxtreme.nl/ols/#features&#34;&#62;&#34;Logic Sniffer features&#34;&#60;/a&#62; lists the ability to add plugins, but there is no point expanding scope to include additions before the basics work.)&#60;/p&#62;
&#60;p&#62;As I wrote, USB will be running on the CPU. That will be 'bursty', which would be worse than random jitter.&#60;br /&#62;
(The Arduino software switches off all interrupts for some sampling rates, but does nothing about them at other sample rates, so it's going to suffer non-random jitter too.)&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;So what sampling rates, and precision as a function of the sampling rate is needed to make the Maple soft logic analyzer an interesting project as a simple but usable tool ???&#34;&#60;/em&#62;&#60;br /&#62;
I think that is a different question. Let me try to be clear where I started.&#60;/p&#62;
&#60;p&#62;I wrote &#60;em&#62;&#34;I am expecting a port to take significantly less than a week&#34;&#60;/em&#62;&#60;br /&#62;
I was unclear about what I'd expect as the result.&#60;/p&#62;
&#60;p&#62;You wrote &#60;em&#62;&#34;It 'works' by just making the minimal changes from arduino to Maple&#34;&#60;/em&#62;&#60;br /&#62;
You posted a small set of changes which got the software running in a Maple, and sampling. That is great work, and very helpful.&#60;/p&#62;
&#60;p&#62;I wrote &#60;em&#62;&#34;it depends what 'works' means&#34;&#60;/em&#62;&#60;br /&#62;
My definition for what 'works' means is relatively simple:&#60;br /&#62;
&#34;Comparable to the Arduino version, across the range of sampling rates the original software supported.&#34;&#60;br /&#62;
Better would be excellent, but worse would be disappointing.&#60;/p&#62;
&#60;p&#62;I am delighted and impressed with your progress. I have no issues if you're goal is different.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mlundinse on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104822</link>
			<pubDate>Fri, 25 Oct 2013 20:37:16 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">104822@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The contention for DMA should be minimal since other activities can be silienced, we are thinking of a Maple devted to this task.&#60;/p&#62;
&#60;p&#62;I have measured the timing loop delays and I cannot make them more precise than 2 clocks, even when a adding single cycle asm instructions, and I get a single cycle error per sample at best even with code running from SRAM, this corresponds to an error of 1/72 = 1.4% for 1MHz sampling rate, useable for logic analysis, but not for precise timing analysis.&#60;/p&#62;
&#60;p&#62;&#34;work&#34; means I can sample a 1 kHz signal from a precise source and get a fairly good representation. The error is always a mixture of quantization errors proportional to the sampling time and accumulated sampling time errors that can be proportional to a multiple of the number of samples taken to measure a signal, thus being proportional to sampling rate and inversely proportional to sampling time.&#60;/p&#62;
&#60;p&#62;So what sampling rates, and precision as a function of the sampling rate is needed to make the Maple soft logic analyzer an interesting project as a simple but usable tool ???
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104821</link>
			<pubDate>Fri, 25 Oct 2013 15:36:32 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104821@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mlundinse - it depends what 'works' means.&#60;/p&#62;
&#60;p&#62;I agree the code translation isn't a lot of work.&#60;br /&#62;
I certainly agree, if all the optimisation needed to sample quickly is deleted, then it is much easier to do the translation.&#60;/p&#62;
&#60;p&#62;This is the core 'capture' function:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void captureMilli() {
	unsigned int i = 0;

	/*
	 * very basic trigger, just like in captureMicros() above.
	 */
	if (trigger) {
		while ((trigger_values ^ CHANPIN) &#38;amp; trigger);
	}

	for (i = 0 ; i &#38;lt; readCount; i++) {
		logicdata[i] = CHANPIN;
		delay(delayTime);
	}

	for (i = 0 ; i &#38;lt; readCount; i++) {
		Serial.write(logicdata[i]);
	}
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It loops, looking for a condition on some of the pins, samples data at a reasonably consistent rate, then write the data to the host.&#60;/p&#62;
&#60;p&#62;Exactly this code could 'work', but it wouldn't have a stable sampling rate unless:&#60;br /&#62;
- it were sampling so slowly interrupts don't matter, or&#60;br /&#62;
- it is only sampling for a fraction of a millisecond, so interrupts can safely be switched off.&#60;/p&#62;
&#60;p&#62;An effort-consuming part of the port &#60;strong&#62;is&#60;/strong&#62; getting the timing correct. That is where I'd expect the time to go in my effort SWAG.&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;... this can be a bit tricky to get right since the Cortex M3 pipeline and STM32 flash preload will make timing very hard to predict.&#34;&#60;/em&#62;&#60;br /&#62;
I agree it is tricky.&#60;br /&#62;
However, if, instead of trying to predict it, one has access to good test gear, it can be measured.&#60;br /&#62;
When we look at disassembled code for a &#60;code&#62;for&#60;/code&#62; loop like&#60;br /&#62;
&#60;code&#62;for (i = 0 ; i &#38;lt; readCount; i++) { logicdata[i] = CHANPIN; }&#60;/code&#62;&#60;br /&#62;
the first iteration can be different, but the middle iterations are usually consistent (without interrupts or DMA), and would show that on good test equipment.&#60;/p&#62;
&#60;p&#62;Of course, DMA could be better. Replacing:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// ...
       for (i = 0 ; i &#38;lt; readCount; i++) {
		logicdata[i] = CHANPIN;
		delay(delayTime);
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;with DMA would reduce the sampling overhead, and offer the potential for a more stable sampling rate. That is certainly the direction I'd want to go.&#60;/p&#62;
&#60;p&#62;However, DMA introduces contention for RAM, and potentially the buses, between DMA and the Cortex CPU. That may be an issue at high speed, or with 'bursty' activity from the CPU (for example servicing the USB interrupt). That would cause sampling to have 'jitter'. So even DMA needs some care.&#60;/p&#62;
&#60;p&#62;&#60;strong&#62;Summary&#60;/strong&#62;&#60;br /&#62;
I agree, getting something to sample is straightforward.&#60;br /&#62;
However, I think users would expect a logic analyser, which writes times on the UI, to be reasonably accurate, with low jitter.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mlundinse on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104819</link>
			<pubDate>Fri, 25 Oct 2013 13:35:47 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">104819@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;It 'works' by just making the minimal changes from arduino to Maple:&#60;br /&#62;
Change Serial -&#38;gt; SerialUSB&#60;br /&#62;
#define CHANPIN GPIOC-&#38;gt;regs-&#38;gt;IDR&#60;br /&#62;
#define CHAN0 10&#60;br /&#62;
#define CHAN1 11&#60;br /&#62;
#define CHAN2 12&#60;br /&#62;
#define CHAN3 13&#60;br /&#62;
#define CHAN4 14&#60;br /&#62;
#define CHAN5 15&#60;br /&#62;
Change cli() -&#38;gt;  asm volatile (&#34;cpsid i&#34;);&#60;br /&#62;
Change sei() -&#38;gt;  asm volatile (&#34;cpsie i&#34;);&#60;br /&#62;
Comment away the 2 and 4 MHz sampling.&#60;br /&#62;
Remove most of the Arduina and Atmega board variant stuff for now.&#60;/p&#62;
&#60;p&#62;This will capture from the analog pins that are loctated at port C[0:5]&#60;/p&#62;
&#60;p&#62;Timing loops will be off, and this can be a bit tricky to get right since the Cortex M3 pipeline and STM32 flash preload will make timing very hard to predict. Still, with some work its possible to get the timing correct to within 2 clock cycles, not great but useful in many situations. &#60;/p&#62;
&#60;p&#62;The timing can probably be improved by using a timer to trigger DMA transfers from the port input register to the buffer.&#60;/p&#62;
&#60;p&#62;I have only made some preliminary tests, and not at all looked at the triggering code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104817</link>
			<pubDate>Fri, 25 Oct 2013 08:28:40 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">104817@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gbulmer,&#60;/p&#62;
&#60;p&#62;overwhelming is 100% positive, and i meant it to be so.&#60;br /&#62;
I simply admired your patience and enthusiasm, that to me is not a bad word.&#60;br /&#62;
Thanks again, and keep it up this way!&#60;br /&#62;
samtal
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104815</link>
			<pubDate>Thu, 24 Oct 2013 12:19:14 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104815@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;samtal - sorry for being a bit overwhelming - I got enthusiastic :-)&#60;/p&#62;
&#60;p&#62;I understand your position.&#60;/p&#62;
&#60;p&#62;I am expecting a port to take significantly less than a week, but that is still a lot of effort when you already have the means to use it with an Arduino.&#60;/p&#62;
&#60;p&#62;When I looked at the SUMP protocol, it didn't look like it had provision for mixed scope and analyser.&#60;br /&#62;
However, anything working is much better than 'perfect' :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104814</link>
			<pubDate>Thu, 24 Oct 2013 07:24:43 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">104814@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks gbulmer for superb, overwhelming yet prompt reply.&#60;/p&#62;
&#60;p&#62;I do agree it could be nice project, and I also believe that if the Arduino got it, the Maple should as well.&#60;br /&#62;
It can be the basis for a more advanced tool like a combined scope-Logic-analyzer that is very common nowadays also in FPGA.&#60;/p&#62;
&#60;p&#62;Unfortunately, to me this is more of a current need for monitoring another project than a general-purpose project, I can not see myself diving into such uncertain project that may take months to accomplish.&#60;/p&#62;
&#60;p&#62;I have an Arduino Mega board on which I will try to run the Arduino supplied program (there is no additional hardware needed).&#60;br /&#62;
and yes, I do have the tools and the knowledge to measure and evaluate the outcome of such.&#60;br /&#62;
If it will work for me - I'll use it and let you know.&#60;br /&#62;
If it does not - I can get a full working solution for less that $100, so why bother?&#60;br /&#62;
In any case - Why not encourage one of the Maple lovers to do the work? As you wrote, it is a nice project, suitable for a software student or graduate.&#60;br /&#62;
Thanks again&#60;br /&#62;
samtal
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104809</link>
			<pubDate>Wed, 23 Oct 2013 09:30:18 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104809@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;samtal  - &#60;em&#62;&#34;Does anyone know of a similar Maple option?&#34;&#60;/em&#62;&#60;br /&#62;
No. I haven't searched actively recently, but I have wanted a Maple-based logic analyser for a while. &#60;/p&#62;
&#60;p&#62;I did find SUMP:&#60;br /&#62;
&#60;a href=&#34;http://www.sump.org/projects/analyzer/&#34; rel=&#34;nofollow&#34;&#62;http://www.sump.org/projects/analyzer/&#60;/a&#62;&#60;br /&#62;
but it is FPGA based, and skipped it until (if) LeafLabs release Oak.&#60;/p&#62;
&#60;p&#62;I'd also looked at GadgetFactory FPGA boards, but I don't think I'd spotted the &#34;Open Bench Logic Sniffer&#34;, so thanks for that link.&#60;/p&#62;
&#60;p&#62;I assume the goal is to use &#60;a href=&#34;http://www.lxtreme.nl/ols/&#34; rel=&#34;nofollow&#34;&#62;http://www.lxtreme.nl/ols/&#60;/a&#62;&#60;br /&#62;
and so implement the SUMP protocol.&#60;/p&#62;
&#60;p&#62;I've had a quick skim of the code at &#60;a href=&#34;https://github.com/gillham/logic_analyzer/blob/master/logic_analyzer.ino&#34; rel=&#34;nofollow&#34;&#62;https://github.com/gillham/logic_analyzer/blob/master/logic_analyzer.ino&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;There are lots of in-line asm statements, but AFAICT, they are all 'no ops', to soak-up CPU cycles, and get the timing right. You'd have to futz around with the equivalent for ARM, however I think that is practical to convert the code; the time consuming part will be getting the delays just right (unless you have access to reasonably good frequency measuring test equipment). I might be able to get access to that sort of equipment, so please ask if you'd like some help.&#60;/p&#62;
&#60;p&#62;Other ATmega specific parts are direct access to digital I/O pins and timers.&#60;/p&#62;
&#60;p&#62;The direct timer stuff doesn't look too difficult. Direct timer access seems to be in their for debugging, so that could be made to work. It seems to generate a 100KHz 'tick' which should be okay for Maple's STM32F103 if its okay for an ATmega.&#60;/p&#62;
&#60;p&#62;Using individual digital I/O pins shouldn't be too awful to port, especially if you use the faster_write/faster_read stuff. &#60;/p&#62;
&#60;p&#62;However there is (at least) one major area which looks slightly sneaky. The code reads a port-worth of pins (8 pins on the ATmega),  with a single direct access. So it looks like it has packed the logic-data samples into one byte. Then the code both uses the 'packed data' (read from the entire 8-bit port) for triggering, and data storage.&#60;/p&#62;
&#60;p&#62;If all of the signals being sampled came into one STM32F port, you could use the same technique. You'd likely have to change the size of some variables as int is different for gcc targeted at ATmega vs gcc targeted at ARM. &#60;/p&#62;
&#60;p&#62;To make it easier, you'd probably have to use the upper or lower 8bits from one of the STM32F's 16-bit ports.&#60;br /&#62;
So if that restriction is okay, then I'd WAG that it is practical to do the translation. Otherwise you are probably going to retain the code which talks to the host PC's logic analyser user interface, and re-engineer the code that does the triggering, sampling and storage.&#60;/p&#62;
&#60;p&#62;Edit: I've skimmed over the SUMp protocol at &#60;a href=&#34;http://www.sump.org/projects/analyzer/protocol/&#34; rel=&#34;nofollow&#34;&#62;http://www.sump.org/projects/analyzer/protocol/&#60;/a&#62;&#60;br /&#62;
It looks like the protocol would handle 32 channels, so you could use an entire 16bit port. It would be possible to use two ports-worth of pins, but the trigger function would get a bit more complex, and all the capture code would need a rewrite. &#60;/p&#62;
&#60;p&#62;There are a bunch of 'captureXXXX' functions, each engineered to work within different constraints of the ATmega and Arduino software. With a bit of care, you might get enough functionality from translating one of them to make the entire exercise worthwhile. That might not be good enough for general use, as the logic analyser UI might be set to ask for an un-translated function. However as a starting point, one working capture function may be BRILLIANT!-)&#60;/p&#62;
&#60;p&#62;If you do decide to try to do the port, please keep us 'in the loop', and I'm sure we'll try to help you; it would be a lovely project.&#60;br /&#62;
If you decide not to do it, please tell us too. I am very busy 'till January, but I might be able to make some time then to have a crack at it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Maple Logic Analyzer?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74071#post-104805</link>
			<pubDate>Mon, 21 Oct 2013 06:18:56 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">104805@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I found an Arduino Logic Analyzer at &#60;a href=&#34;http://letsmakerobots.com/node/31422&#34; rel=&#34;nofollow&#34;&#62;http://letsmakerobots.com/node/31422&#60;/a&#62;.&#60;br /&#62;
It runs with &#60;a href=&#34;http://www.lxtreme.nl/ols/&#34; rel=&#34;nofollow&#34;&#62;http://www.lxtreme.nl/ols/&#60;/a&#62; Logic Analyzer application.&#60;/p&#62;
&#60;p&#62;Does anyone know of a similar Maple option?&#60;br /&#62;
Can (How?) that Arduino be ported to Maple R5 (or other)?&#60;br /&#62;
Thanks
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
