10 Commits

Author SHA1 Message Date
Andrew Gillham
9c83897b9b Correct preprocessor logic to avoid data gap on the Mega.
Fixes issue #14 where I copied the preprocessor logic from a different
Mega related check and didn't fix up the elif.  So samples from 512 -
1023 were always zero on the Mega.
Update to v0.12
2013-09-06 09:54:41 -07:00
Andrew Gillham
2a549be57a Tweak README 2013-08-03 13:25:54 -07:00
Andrew Gillham
2d31a93687 Add notes about 2MHz/4MHz mode and binary size.
Also move a couple more things under #ifdef DEBUG in an attempt to
reduce the code size for ATmega168.
It current doesn't fit in the '168 but maybe after some more tweaks.
2013-08-03 13:23:02 -07:00
Andrew Gillham
d7c1bf52a8 Add 2MHz and 4MHz sample rate support.
Use unrolled loops to sample at 2MHz & 4MHz rates.  Based on some
testing by Bob Davis (http://bobdavis321.blogspot.com)
The maximum with a 16MHz clock is 5.3333MHz (3 cycles per sample) but
sampling at that rate isn't very accurate.  Accuracy is pretty good at
2MHz & 4MHz.
2013-08-03 12:33:23 -07:00
Andrew Gillham
69de405dd5 Release v0.10 with a fix for the Arduino Uno R3.
The only change is an updated ols.profile-agla.cfg that works with the
Arduino Uno R3.
2013-07-22 22:25:24 -07:00
Andrew Gillham
8c7db04e3c Increase portdelay so that Arduino Uno R3 works.
For some reason the Arduino Uno R3 (but not my earlier / original Uno)
needs a longer delay after reset.  I haven't investigated the cause
yet, but increasing device.open.portdelay to > 1700ms seems to fix it.
Bump to 2000 just to be safe in all cases.  This should fix the Uno R3
issues that have been reported a couple of times now.
2013-07-22 22:11:20 -07:00
Andrew Gillham
17d2a1a15f Bump metadata for version 0.09 2013-06-22 19:22:35 -07:00
Andrew Gillham
0a40fdb2ac Update comment to reflect that PORTD seems to work, but needs testing.
I'm still working on PORTD triggers.  I'm not yet satisfied they are
working 100% correctly.
2013-06-22 11:33:29 -07:00
Andrew Gillham
1f7eb0aecd Add missing shift for PORTD trigger. 2013-06-22 11:30:39 -07:00
Andrew Gillham
dc3d85abf7 Revert to PORTB (Arduino pins 8-13) and make PORTD a configuration option.
Triggers are more reliable on PORTB.  I am working on fixing triggers
on PORTD, but I'm setting this back to original behavior (with a
#define USE_PORTD available) so this isn't broken for triggering.
2013-06-22 11:17:06 -07:00
6 changed files with 29045 additions and 23 deletions

14
README
View File

@@ -1,8 +1,14 @@
SUMP compatible logic analyzer for Arduino
==========================================
NOTE: v0.08 switches the channels to pins 2-7 NOT 8-13 any longer.
Please report any issues. For old behavior use v0.07.
NOTE: With v0.11 you can now sample at 4MHz & 2MHz rates in addition to the
previous 1MHz and lower rates. This is done via unrolled loops which
makes the source code huge and the binary takes much more of the flash.
v0.11 is just slightly to big for an ATmega168's flash. You can comment
out either captureInline2mhz() or captureInline4mhz() and it will fit.
NOTE: v0.09 switched the channels BACK to pins 8-13 for trigger reliability.
Please report any issues. Uncomment USE_PORTD for pins 2-7.
This Arduino sketch implements a SUMP protocol compatible with the standard
SUMP client as well as the alternative client from here:
@@ -37,7 +43,7 @@ platform, but on the mac it is here by default:
To use this with the original or alternative SUMP clients,
use these settings:
Sampling rate: 1MHz (or lower)
Sampling rate: 4MHz (or lower)
Channel Groups: 0 (zero) only
Recording Size:
ATmega168: 532 (or lower)
@@ -54,5 +60,5 @@ Please try it out and report back.
This master branch now supports Arduino 1.0 only.
Checkout branch logic_analyzer_v0_5 for Arduino 22 support.
Release: v0.08 February 8, 2013.
Release: v0.12 September 6, 2013.

View File

@@ -25,13 +25,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: logic_analyzer.ino,v 1.21 2012/02/27 20:19:44 gillham Exp $
*
*/
/*
* NOTE: v0.08 switches the channels to pins 2-7 NOT 8-13 any longer.
* Please report any issues. For old behavior use v0.07.
* NOTE: v0.09 switched the channels BACK to pins 8-13 for trigger reliability.
* Please report any issues. Uncomment USE_PORTD for pins 2-7.
*
* This Arduino sketch implements a SUMP protocol compatible with the standard
* SUMP client as well as the alternative client from here:
@@ -64,7 +63,7 @@
* To use this with the original or alternative SUMP clients,
* use these settings:
*
* Sampling rate: 1MHz (or lower)
* Sampling rate: 4MHz (or lower)
* Channel Groups: 0 (zero) only
* Recording Size:
* ATmega168: 532 (or lower)
@@ -79,7 +78,7 @@
* until after the trigger fires.
* Please try it out and report back.
*
* Release: v0.08 February 8, 2013.
* Release: v0.12 September 6, 2013.
*
*/
@@ -99,6 +98,13 @@ void get_metadata(void);
void debugprint(void);
void debugdump(void);
/*
* Should we use PORTD or PORTB? (default is PORTB)
* PORTD support with triggers seems to work but needs more testing.
*/
//#define USE_PORTD 1
/*
* Arduino device profile: ols.profile-agla.cfg
* Arduino Mega device profile: ols.profile-aglam.cfg
@@ -114,6 +120,7 @@ void debugdump(void);
#define CHAN6 28
#define CHAN7 29
#else
#if defined(USE_PORTD)
#define CHANPIN PIND
#define CHAN0 2
#define CHAN1 3
@@ -121,6 +128,16 @@ void debugdump(void);
#define CHAN3 5
#define CHAN4 6
#define CHAN5 7
#else
#define CHANPIN PINB
#define CHAN0 8
#define CHAN1 9
#define CHAN2 10
#define CHAN3 11
#define CHAN4 12
/* Comment out CHAN5 if you don't want to use the LED pin for an input */
#define CHAN5 13
#endif /* USE_PORTD */
#endif
#define ledPin 13
@@ -161,9 +178,15 @@ void debugdump(void);
#define CAPTURE_SIZE 532
#endif
#ifdef USE_PORTD
#define DEBUG_ENABLE DDRB = DDRB | B00000001
#define DEBUG_ON PORTB = B00000001
#define DEBUG_OFF PORTB = B00000000
#else
#define DEBUG_ENABLE DDRD = DDRD | B10000000
#define DEBUG_ON PORTD = B10000000
#define DEBUG_OFF PORTD = B00000000
#endif
#define DEBUG
#ifdef DEBUG
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
@@ -212,12 +235,42 @@ void setup()
pinMode(CHAN2, INPUT);
pinMode(CHAN3, INPUT);
pinMode(CHAN4, INPUT);
#ifdef CHAN5
pinMode(CHAN5, INPUT);
#endif
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
pinMode(CHAN6, INPUT);
pinMode(CHAN7, INPUT);
#endif /* Mega */
#else
#ifndef CHAN5
pinMode(ledPin, OUTPUT);
#endif
#endif /* Mega */
#if 0
/*
* This sets up timer2 at 100KHz to toggle a pin. This is useful
* for debugging as it gives an internally precise signal source.
* This doesn't work on the Arduino Mega. Use on the Uno or older.
* We're using the same clock source for the timer & our sampling.
*/
/* Set OC2A (digital pin 11) to output so we can toggle it. */
pinMode(11, OUTPUT);
/* reset timer to zero */
TCNT2 = 0;
TCCR2A = 0;
TCCR2B = 0;
OCR2A = 0;
/* Set CTC mode and toggle on compare. */
TCCR2A = _BV (COM2A0) | _BV (WGM21);
/* 79 = 100KHz, 15 = 500KHz, 7 = 1MHz */
OCR2A = 79;
TCCR2B = _BV (CS20);
#endif
}
void loop()
@@ -255,7 +308,16 @@ void loop()
* so in that case (delayTime == 1 and triggers enabled) use
* captureMicro() instead of triggerMicro().
*/
if (useMicro) {
if (divider == 24) {
/* 4.0MHz */
captureInline4mhz();
}
else if (divider == 49) {
/* 2.0MHz */
captureInline2mhz();
}
else if (useMicro) {
if (trigger && (delayTime != 1)) {
triggerMicro();
}
@@ -273,7 +335,11 @@ void loop()
* we can just use it directly as our trigger mask.
*/
getCmd();
#ifdef USE_PORTD
trigger = cmdBytes[0] << 2;
#else
trigger = cmdBytes[0];
#endif
break;
case SUMP_TRIGGER_VALUES:
/*
@@ -281,7 +347,11 @@ void loop()
* defines whether we're looking for it to be high or low.
*/
getCmd();
#ifdef USE_PORTD
trigger_values = cmdBytes[0] << 2;
#else
trigger_values = cmdBytes[0];
#endif
break;
case SUMP_TRIGGER_CONFIG:
/* read the rest of the command bytes, but ignore them. */
@@ -421,7 +491,7 @@ void getCmd() {
*/
void captureMicro() {
int i;
unsigned int i;
/*
* basic trigger, wait until all trigger conditions are met on port.
@@ -446,6 +516,7 @@ void captureMicro() {
* Arduino digital pin 8 is being used here.
*/
DEBUG_ENABLE;
#ifdef DEBUG
DEBUG_ON;
delayMicroseconds(20);
DEBUG_OFF;
@@ -454,6 +525,7 @@ void captureMicro() {
delayMicroseconds(20);
DEBUG_OFF;
delayMicroseconds(20);
#endif
if (delayTime == 1) {
/*
@@ -509,7 +581,11 @@ void captureMicro() {
* is done for any triggers, this is effectively the 0/100 buffer split.
*/
for (i = 0 ; i < readCount; i++) {
#ifdef USE_PORTD
Serial.write(logicdata[i] >> 2);
#else
Serial.write(logicdata[i]);
#endif
}
}
@@ -531,7 +607,7 @@ void captureMicro() {
* this basic functionality.
*/
void captureMilli() {
int i = 0;
unsigned int i = 0;
if(rleEnabled) {
/*
@@ -580,7 +656,11 @@ void captureMilli() {
}
}
for (i = 0 ; i < readCount; i++) {
#ifdef USE_PORTD
Serial.write(logicdata[i] >> 2);
#else
Serial.write(logicdata[i]);
#endif
}
}
@@ -593,7 +673,7 @@ void captureMilli() {
*
*/
void triggerMicro() {
int i = 0;
unsigned int i = 0;
logicIndex = 0;
triggerIndex = 0;
@@ -613,6 +693,7 @@ void triggerMicro() {
* Arduino digital pin 8 is being used here.
*/
DEBUG_ENABLE;
#ifdef DEBUG
DEBUG_ON;
delayMicroseconds(20);
DEBUG_OFF;
@@ -621,6 +702,7 @@ void triggerMicro() {
delayMicroseconds(20);
DEBUG_OFF;
delayMicroseconds(20);
#endif
if (delayTime == 1) {
/*
@@ -768,7 +850,11 @@ void triggerMicro() {
if (logicIndex >= readCount) {
logicIndex = 0;
}
#ifdef USE_PORTD
Serial.write(logicdata[logicIndex++] >> 2);
#else
Serial.write(logicdata[logicIndex++]);
#endif
}
}
@@ -820,8 +906,8 @@ void get_metadata() {
Serial.write((uint8_t)0x02);
Serial.write('0');
Serial.write('.');
Serial.write('0');
Serial.write('8');
Serial.write('1');
Serial.write('2');
Serial.write((uint8_t)0x00);
/* sample memory */
@@ -842,19 +928,23 @@ void get_metadata() {
Serial.write((uint8_t)0x14);
#endif /* Mega */
/* sample rate (1MHz) */
/* sample rate (4MHz) */
Serial.write((uint8_t)0x23);
Serial.write((uint8_t)0x00);
Serial.write((uint8_t)0x0F);
Serial.write((uint8_t)0x42);
Serial.write((uint8_t)0x40);
Serial.write((uint8_t)0x3D);
Serial.write((uint8_t)0x09);
Serial.write((uint8_t)0x00);
/* number of probes (6 by default on Arduino, 8 on Mega) */
Serial.write((uint8_t)0x40);
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
Serial.write((uint8_t)0x08);
#else
#ifdef CHAN5
Serial.write((uint8_t)0x06);
#else
Serial.write((uint8_t)0x05);
#endif /* CHAN5 */
#endif /* Mega */
/* protocol version (2) */
@@ -918,7 +1008,11 @@ void debugdump() {
Serial.print("\r\n");
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
#ifdef USE_PORTD
Serial.print(logicdata[i] >> 2, HEX);
#else
Serial.print(logicdata[i], HEX);
#endif
Serial.print(" ");
if (j == 32) {
Serial.print("\r\n");
@@ -929,3 +1023,13 @@ void debugdump() {
}
#endif /* DEBUG */

14456
logic_analyzer_inline_2mhz.ino Normal file

File diff suppressed because it is too large Load Diff

14456
logic_analyzer_inline_4mhz.ino Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ device.clockspeed = 16000000
# Whether or not double-data-rate is supported by the device (also known as the "demux"-mode).
device.supports_ddr = false
# Supported sample rates in Hertz, separated by comma's
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 4000000
# What capture clocks are supported
device.captureclock = INTERNAL
# The supported capture sizes, in bytes
@@ -39,7 +39,7 @@ device.capturesize.bound = false
device.channel.numberingschemes = DEFAULT
# Is a delay after opening the port and device detection needed? (0 = no delay, >0 = delay in milliseconds)
device.open.portdelay = 1500
device.open.portdelay = 2000
# The receive timeout for the device (in milliseconds, 100 = default, <=0 = no timeout)
device.receive.timeout = 100
# Does the device need a high or low DTR-line to operate correctly? (high = true, low = false)

View File

@@ -11,7 +11,7 @@ device.clockspeed = 16000000
# Whether or not double-data-rate is supported by the device (also known as the "demux"-mode).
device.supports_ddr = false
# Supported sample rates in Hertz, separated by comma's
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 4000000
# What capture clocks are supported
device.captureclock = INTERNAL
# The supported capture sizes, in bytes