1 Commits

Author SHA1 Message Date
Andrew Gillham
d31d662ede Add device profile for Arduino logic analyzer
Use this device profile with the alternative SUMP client.  It goes in
the plugins directory with the other similarly named files.
2011-08-03 19:43:09 -07:00
4 changed files with 65 additions and 220 deletions

24
README
View File

@@ -12,34 +12,19 @@ crystal oscillator pins.
Uncomment CHAN5 below if you want to use the LED pin as an input and have
6 channels.
On the Arduino Mega board 8 channels are supported and 7k of samples.
Pins 22-29 (Port A) are used by default, you can change the 'CHANPIN' below
if something else works better for you.
NOTE:
If you are using the original SUMP client, or using the alternative client
without the device profiles, then you will get a "device not found" error.
You must DISABLE the Arduino auto reset feature to use this logic analyzer
code. There are various methods to do this, some boards have a jumper,
others require you to cut a trace. You may also install a *precisely*
120 Ohm resistor between the reset & 5V piins. Make sure it is really
120 Ohm or you may damage your board. It is much easier to use the
alternative SUMP client referenced above.
The device profiles should be included with this code. Copy them to the
'plugins' directory of the client. The location varies depending on the
platform, but on the mac it is here by default:
/Applications/LogicSniffer.app/Contents/Resources/Java/plugins
120 Ohm or you may damage your board.
To use this with the original or alternative SUMP clients,
use these settings:
Sampling rate: 1MHz (or lower)
Channel Groups: 0 (zero) only
Recording Size:
ATmega168: 532 (or lower)
ATmega328: 1024 (or lower)
ATmega2560: 7168 (or lower)
Recording Size: 1024 (or lower)
Noise Filter: doesn't matter
RLE: disabled (unchecked)
@@ -48,8 +33,5 @@ below 1MHz. 1MHz works for a basic busy wait trigger that doesn't store
until after the trigger fires.
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.06 November 4, 2011.
Release: v0.03 March 7, 2011.

View File

@@ -25,15 +25,11 @@
* (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 $
* $Id: logic_analyzer.pde,v 1.14 2011-03-08 07:14:42 gillham Exp $
*
*/
/*
* This Arduino sketch implements a SUMP protocol compatible with the standard
* SUMP client as well as the alternative client from here:
* http://www.lxtreme.nl/ols/
*
* This SUMP protocol compatible logic analyzer for the Arduino board supports
* 5 channels consisting of digital pins 8-12, which are the first 5 bits (0-4)
* of PORTB. Arduino pin 13 / bit 5 is the Arduino LED, bits 6 & 7 are the
@@ -41,35 +37,19 @@
* Uncomment CHAN5 below if you want to use the LED pin as an input and have
* 6 channels.
*
* On the Arduino Mega board 8 channels are supported and 7k of samples.
* Pins 22-29 (Port A) are used by default, you can change the 'CHANPIN' below
* if something else works better for you.
*
* NOTE:
* If you are using the original SUMP client, or using the alternative client
* without the device profiles, then you will get a "device not found" error.
* You must DISABLE the Arduino auto reset feature to use this logic analyzer
* code. There are various methods to do this, some boards have a jumper,
* others require you to cut a trace. You may also install a *precisely*
* 120 Ohm resistor between the reset & 5V piins. Make sure it is really
* 120 Ohm or you may damage your board.
* It is much easier to use the alternative SUMP client from here:
* http://www.lxtreme.nl/ols/
*
* The device profiles should be included with this code. Copy them to the
* 'plugins' directory of the client. The location varies depending on the
* platform, but on the mac it is here by default:
* /Applications/LogicSniffer.app/Contents/Resources/Java/plugins
*
* To use this with the original or alternative SUMP clients,
* use these settings:
*
* Sampling rate: 1MHz (or lower)
* Channel Groups: 0 (zero) only
* Recording Size:
* ATmega168: 532 (or lower)
* ATmega328: 1024 (or lower)
* ATmega2560: 7168 (or lower)
* Recording Size: 1024 (or lower)
* Noise Filter: doesn't matter
* RLE: disabled (unchecked)
*
@@ -78,7 +58,7 @@
* until after the trigger fires.
* Please try it out and report back.
*
* Release: v0.06 November 4, 2011.
* Release: v0.02 February 28, 2011.
*
*/
@@ -99,31 +79,15 @@ void debugprint(void);
void debugdump(void);
/*
* Uncomment CHAN5 to use it as an additional input on a normal Arduino.
* Uncomment CHAN5 to use it as an additional input.
* You'll need to change the number of channels in the device profile as well.
*
* Arduino device profile: ols.profile-agla.cfg
* Arduino Mega device profile: ols.profile-aglam.cfg
*/
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define CHANPIN PINA
#define CHAN0 22
#define CHAN1 23
#define CHAN2 24
#define CHAN3 25
#define CHAN4 26
#define CHAN5 27
#define CHAN6 28
#define CHAN7 29
#else
#define CHANPIN PINB
#define CHAN0 8
#define CHAN1 9
#define CHAN2 10
#define CHAN3 11
#define CHAN4 12
//#define CHAN5 13
#endif
#define ledPin 13
/* XON/XOFF are not supported. */
@@ -147,26 +111,15 @@ void debugdump(void);
#define SUMP_SELF_TEST 0x03
#define SUMP_GET_METADATA 0x04
/* ATmega168: 532 (or lower)
* ATmega328: 1024 (or lower)
* ATmega2560: 7168 (or lower)
/*
* Capture size of 1024 bytes works on the ATmega328.
*
*/
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define DEBUG_CAPTURE_SIZE 7168
#define CAPTURE_SIZE 7168
#elif defined(__AVR_ATmega328P__)
#define DEBUG_CAPTURE_SIZE 1024
#define CAPTURE_SIZE 1024
#else
#define DEBUG_CAPTURE_SIZE 532
#define CAPTURE_SIZE 532
#endif
#define DEBUG
#ifdef DEBUG
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
#define MAX_CAPTURE_SIZE 1024
#else
#define MAX_CAPTURE_SIZE CAPTURE_SIZE
#define MAX_CAPTURE_SIZE 1024
#endif /* DEBUG */
/*
@@ -209,18 +162,11 @@ void setup()
pinMode(CHAN2, INPUT);
pinMode(CHAN3, INPUT);
pinMode(CHAN4, INPUT);
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
pinMode(CHAN5, INPUT);
pinMode(CHAN6, INPUT);
pinMode(CHAN7, INPUT);
pinMode(ledPin, OUTPUT);
#else
#ifdef CHAN5
pinMode(CHAN5, INPUT);
#else
pinMode(ledPin, OUTPUT);
#endif /* CHAN5 */
#endif /* Mega */
}
void loop()
@@ -239,10 +185,10 @@ void loop()
break;
case SUMP_QUERY:
/* return the expected bytes. */
Serial.write('1');
Serial.write('A');
Serial.write('L');
Serial.write('S');
Serial.print('1', BYTE);
Serial.print('A', BYTE);
Serial.print('L', BYTE);
Serial.print('S', BYTE);
break;
case SUMP_ARM:
/*
@@ -376,12 +322,14 @@ void loop()
}
}
#ifndef CHAN5
void blinkled() {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
#endif /* !CHAN5 */
/*
* Extended SUMP commands are 5 bytes. A command byte followed by 4 bytes
@@ -432,7 +380,7 @@ void captureMicro() {
* this needs further testing, but basic tests work as expected.
*/
if (trigger) {
while ((trigger_values ^ CHANPIN) & trigger);
while ((trigger_values ^ PINB) & trigger);
}
/*
@@ -466,7 +414,7 @@ void captureMicro() {
*/
PORTD = B10000000; /* debug timing measurement */
for (i = 0 ; i < readCount; i++) {
logicdata[i] = CHANPIN;
logicdata[i] = PINB;
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
}
@@ -479,7 +427,7 @@ void captureMicro() {
*/
PORTD = B10000000; /* debug timing measurement */
for (i = 0 ; i < readCount; i++) {
logicdata[i] = CHANPIN;
logicdata[i] = PINB;
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
@@ -498,7 +446,7 @@ void captureMicro() {
*/
PORTD = B10000000; /* debug timing measurement */
for (i = 0 ; i < readCount; i++) {
logicdata[i] = CHANPIN;
logicdata[i] = PINB;
delayMicroseconds(delayTime - 1);
__asm__("nop\n\t""nop\n\t");
}
@@ -513,7 +461,7 @@ void captureMicro() {
* is done for any triggers, this is effectively the 0/100 buffer split.
*/
for (i = 0 ; i < readCount; i++) {
Serial.write(logicdata[i]);
Serial.print(logicdata[i], BYTE);
}
}
@@ -541,15 +489,15 @@ void captureMilli() {
* very basic trigger, just like in captureMicros() above.
*/
if (trigger) {
while ((trigger_values ^ CHANPIN) & trigger);
while ((trigger_values ^ PINB) & trigger);
}
for (i = 0 ; i < readCount; i++) {
logicdata[i] = CHANPIN;
logicdata[i] = PINB;
delay(delayTime);
}
for (i = 0 ; i < readCount; i++) {
Serial.write(logicdata[i]);
Serial.print(logicdata[i], BYTE);
}
}
@@ -609,12 +557,12 @@ void triggerMicro() {
/*
* 500KHz case. We should be able to manage this in time.
*
* busy loop reading CHANPIN until we trigger.
* busy loop reading PINB until we trigger.
* we always start capturing at the start of the buffer
* and use it as a circular buffer
*/
PORTD = B10000000; /* debug timing measurement */
while ((trigger_values ^ (logicdata[logicIndex] = CHANPIN)) & trigger) {
while ((trigger_values ^ (logicdata[logicIndex] = PINB)) & trigger) {
/* PORTD = B00000000; */
/* increment index. */
logicIndex++;
@@ -656,7 +604,7 @@ void triggerMicro() {
if (logicIndex >= readCount) {
logicIndex = 0;
}
logicdata[logicIndex++] = CHANPIN;
logicdata[logicIndex++] = PINB;
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
@@ -669,25 +617,19 @@ void triggerMicro() {
* Less than 500KHz case. This uses delayMicroseconds() and some padding
* to get precise timing, at least for the after trigger samples.
*
* busy loop reading CHANPIN until we trigger.
* busy loop reading PINB until we trigger.
* we always start capturing at the start of the buffer
* and use it as a circular buffer
*
*/
PORTD = B10000000; /* debug timing measurement */
while ((trigger_values ^ (logicdata[logicIndex] = CHANPIN)) & trigger) {
while ((trigger_values ^ (logicdata[logicIndex] = PINB)) & trigger) {
/* PORTD = B00000000; */
/* increment index. */
logicIndex++;
if (logicIndex >= readCount) {
logicIndex = 0;
}
else {
/* pad the same number of cycles as the above assignment (needs verification) */
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
}
delayMicroseconds(delayTime - 3);
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
/* PORTD = B10000000; */
}
PORTD = B00000000; /* debug timing measurement */
@@ -699,10 +641,7 @@ void triggerMicro() {
* This needs adjustment so that we have the right spacing between the
* before trigger samples and the after trigger samples.
*/
delayMicroseconds(delayTime - 2);
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t");
delayMicroseconds(delayTime);
/* keep sampling for delayCount after trigger */
PORTD = B10000000; /* debug timing measurement */
@@ -710,7 +649,7 @@ void triggerMicro() {
if (logicIndex >= readCount) {
logicIndex = 0;
}
logicdata[logicIndex++] = CHANPIN;
logicdata[logicIndex++] = PINB;
delayMicroseconds(delayTime - 3);
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
@@ -737,7 +676,7 @@ void triggerMicro() {
if (logicIndex >= readCount) {
logicIndex = 0;
}
Serial.write(logicdata[logicIndex++]);
Serial.print(logicdata[logicIndex++], BYTE);
}
}
@@ -773,61 +712,43 @@ void setupDelay() {
*/
void get_metadata() {
/* device name */
Serial.write((uint8_t)0x01);
Serial.write('A');
Serial.write('G');
Serial.write('L');
Serial.write('A');
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
Serial.write('M');
#endif /* Mega */
Serial.write('v');
Serial.write('0');
Serial.write((uint8_t)0x00);
Serial.print(0x01, BYTE);
Serial.print('A', BYTE);
Serial.print('G', BYTE);
Serial.print('L', BYTE);
Serial.print('A', BYTE);
Serial.print('v', BYTE);
Serial.print('0', BYTE);
Serial.print(0x00, BYTE);
/* sample memory */
Serial.write((uint8_t)0x21);
Serial.write((uint8_t)0x00);
Serial.write((uint8_t)0x00);
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
/* 7168 bytes */
Serial.write((uint8_t)0x1C);
Serial.write((uint8_t)0x00);
#elif defined(__AVR_ATmega328P__)
/* 1024 bytes */
Serial.write((uint8_t)0x04);
Serial.write((uint8_t)0x00);
#else
/* 532 bytes */
Serial.write((uint8_t)0x02);
Serial.write((uint8_t)0x14);
#endif /* Mega */
/* sample memory (1024) */
Serial.print(0x21, BYTE);
Serial.print(0x00, BYTE);
Serial.print(0x00, BYTE);
Serial.print(0x04, BYTE);
Serial.print(0x00, BYTE);
/* sample rate (1MHz) */
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.print(0x23, BYTE);
Serial.print(0x00, BYTE);
Serial.print(0x0F, BYTE);
Serial.print(0x42, BYTE);
Serial.print(0x40, BYTE);
/* number of probes (5 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
/* number of probes (5 by default) */
Serial.print(0x40, BYTE);
#ifdef CHAN5
Serial.write((uint8_t)0x06);
Serial.print(0x06, BYTE);
#else
Serial.write((uint8_t)0x05);
Serial.print(0x05, BYTE);
#endif /* CHAN5 */
#endif /* Mega */
/* protocol version (2) */
Serial.write((uint8_t)0x41);
Serial.write((uint8_t)0x02);
Serial.print(0x41, BYTE);
Serial.print(0x02, BYTE);
/* end of data */
Serial.write((uint8_t)0x00);
Serial.print(0x00, BYTE);
}
/*
@@ -864,7 +785,7 @@ void debugprint() {
}
else {
Serial.print(savebytes[i], HEX);
Serial.write(' ');
Serial.print(' ', BYTE);
}
}
Serial.println("done...");
@@ -893,6 +814,3 @@ void debugdump() {
#endif /* DEBUG */

View File

@@ -7,7 +7,7 @@ device.description = Arduino Generic Logic Analyzer
# The device interface, SERIAL only
device.interface = SERIAL
# The device's native clockspeed, in Hertz.
device.clockspeed = 16000000
device.clockspeed = 100000000
# 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
@@ -39,15 +39,13 @@ 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
# The receive timeout for the device (in milliseconds, 100 = default, <=0 = no timeout)
device.receive.timeout = 100
device.open.portdelay = 500
# Does the device need a high or low DTR-line to operate correctly? (high = true, low = false)
device.open.portdtr = true
# Which metadata keys correspond to this device profile? Value is a comma-separated list of (double quoted) names...
device.metadata.keys = "AGLAv0"
# In which order are samples sent back from the device? false = last sample first, true = first sample first
device.samples.reverseOrder = true
# In which order are samples sent back from the device? true = last sample first, false = first sample first
device.samples.reverseOrder = false
###EOF###

View File

@@ -1,53 +0,0 @@
# Configuration for Arduino Mega Logic Analyzer profile
# The short (single word) type of the device described in this profile
device.type = AGLAM
# A longer description of the device
device.description = Arduino Mega Logic Analyzer
# The device interface, SERIAL only
device.interface = SERIAL
# The device's native clockspeed, in Hertz.
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
# What capture clocks are supported
device.captureclock = INTERNAL
# The supported capture sizes, in bytes
device.capturesizes = 64, 128, 256, 512, 1024, 2048, 4096, 7168
# Whether or not the noise filter is supported
device.feature.noisefilter = false
# Whether or not Run-Length encoding is supported
device.feature.rle = false
# Whether or not a testing mode is supported
device.feature.testmode = false
# Whether or not triggers are supported
device.feature.triggers = true
# The number of trigger stages
device.trigger.stages = 1
# Whether or not "complex" triggers are supported
device.trigger.complex = false
# The total number of channels usable for capturing
device.channel.count = 8
# The number of channels groups, together with the channel count determines the channels per group
device.channel.groups = 1
# Whether the capture size is limited by the enabled channel groups
device.capturesize.bound = false
# Which numbering does the device support
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 = 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)
device.open.portdtr = true
# Which metadata keys correspond to this device profile? Value is a comma-separated list of (double quoted) names...
device.metadata.keys = "AGLAMv0"
# In which order are samples sent back from the device? false = last sample first, true = first sample first
device.samples.reverseOrder = true
###EOF###