2 Commits

Author SHA1 Message Date
Andrew Gillham
8e7a780577 Tweak README 2013-08-03 13:26:44 -07:00
Andrew Gillham
51df725ee8 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:24:18 -07:00
4 changed files with 77 additions and 105 deletions

69
README
View File

@@ -1,28 +1,49 @@
SUMP compatible logic analyzer for Arduino
==========================================
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:
http://www.lxtreme.nl/ols/
The alternative client version is highly recommended. Download version
"ols-0.9.7" or newer for built-in device profiles.
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
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.
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
To use this with the original or alternative SUMP clients,
use these settings:
Sampling rate: 4MHz (or lower) (no 2MHz on ATmega168)
Sampling rate: 4MHz (or lower)
Channel Groups: 0 (zero) only
Recording Size:
ATmega168: 532 (or lower)
@@ -36,38 +57,8 @@ 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.
Older Notes
===========================================================================
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.
[ The code automatically skips the 2MHz code now, this isn't needed. ]
This master branch now supports Arduino 1.0 only.
Checkout branch logic_analyzer_v0_5 for Arduino 22 support.
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.
NOTE: 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
[ These are included in ols-0.9.7 or newer so do not copy them. ]
NOTE: If you are using the original SUMP client, 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.
[ This is not needed with ols-0.9.7 or newer. ]
[ DO NOT use this resistor unless absolutely necessary on old clients. ]
NOTE: This master branch now supports Arduino 1.0 only.
Checkout branch logic_analyzer_v0_5 for Arduino 22 support.
Release: v0.12 September 6, 2013.
Release: v0.11 August 3, 2013.

View File

@@ -2,7 +2,7 @@
*
* SUMP Protocol Implementation for Arduino boards.
*
* Copyright (c) 2011,2012,2013,2014 Andrew Gillham
* Copyright (c) 2011,2012,2013 Andrew Gillham
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,10 +44,26 @@
* 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: 4MHz (or lower) (no 2MHz on ATmega168)
* Sampling rate: 4MHz (or lower)
* Channel Groups: 0 (zero) only
* Recording Size:
* ATmega168: 532 (or lower)
@@ -62,7 +78,7 @@
* until after the trigger fires.
* Please try it out and report back.
*
* Release: v0.12 September 6, 2013.
* Release: v0.11 August 3, 2013.
*
*/
@@ -88,11 +104,6 @@ void debugdump(void);
* PORTD support with triggers seems to work but needs more testing.
*/
//#define USE_PORTD 1
#if defined(USE_PORTD)
#define SHIFTBITS 2
#elif defined(__AVR_ATmega32U4__)
#define SHIFTBITS 1
#endif
/*
* Arduino device profile: ols.profile-agla.cfg
@@ -119,15 +130,6 @@ void debugdump(void);
#define CHAN5 7
#else
#define CHANPIN PINB
#if defined(__AVR_ATmega32U4__)
#define CHAN0 SCK
#define CHAN1 MOSI
#define CHAN2 MISO
#define CHAN3 8
#define CHAN4 9
#define CHAN5 10
#define CHAN6 11
#else
#define CHAN0 8
#define CHAN1 9
#define CHAN2 10
@@ -135,9 +137,8 @@ void debugdump(void);
#define CHAN4 12
/* Comment out CHAN5 if you don't want to use the LED pin for an input */
#define CHAN5 13
#endif /* AVR_ATmega32U4 */
#endif /* USE_PORTD */
#endif /* Mega1280 or Mega2560 */
#endif
#define ledPin 13
/* XON/XOFF are not supported. */
@@ -169,9 +170,6 @@ void debugdump(void);
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define DEBUG_CAPTURE_SIZE 7168
#define CAPTURE_SIZE 7168
#elif defined(__AVR_ATmega32U4__)
#define DEBUG_CAPTURE_SIZE 1536
#define CAPTURE_SIZE 1536
#elif defined(__AVR_ATmega328P__)
#define DEBUG_CAPTURE_SIZE 1024
#define CAPTURE_SIZE 1024
@@ -223,10 +221,6 @@ boolean rleEnabled = 0;
void setup()
{
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
/*
* set debug pin (digital pin 8) to output right away so it settles.
@@ -244,15 +238,14 @@ void setup()
#ifdef CHAN5
pinMode(CHAN5, INPUT);
#endif
#ifdef CHAN6
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
pinMode(CHAN6, INPUT);
#endif
#ifdef CHAN7
pinMode(CHAN7, INPUT);
#endif
#else
#ifndef CHAN5
pinMode(ledPin, OUTPUT);
#endif
#endif /* Mega */
#if 0
@@ -322,9 +315,7 @@ void loop()
}
else if (divider == 49) {
/* 2.0MHz */
#if defined(__AVR_ATmega168P__)
captureInline2mhz();
#endif
}
else if (useMicro) {
if (trigger && (delayTime != 1)) {
@@ -344,8 +335,8 @@ void loop()
* we can just use it directly as our trigger mask.
*/
getCmd();
#ifdef SHIFTBITS
trigger = cmdBytes[0] << SHIFTBITS;
#ifdef USE_PORTD
trigger = cmdBytes[0] << 2;
#else
trigger = cmdBytes[0];
#endif
@@ -356,8 +347,8 @@ void loop()
* defines whether we're looking for it to be high or low.
*/
getCmd();
#ifdef SHIFTBITS
trigger_values = cmdBytes[0] << SHIFTBITS;
#ifdef USE_PORTD
trigger_values = cmdBytes[0] << 2;
#else
trigger_values = cmdBytes[0];
#endif
@@ -590,8 +581,8 @@ void captureMicro() {
* is done for any triggers, this is effectively the 0/100 buffer split.
*/
for (i = 0 ; i < readCount; i++) {
#ifdef SHIFTBITS
Serial.write(logicdata[i] >> SHIFTBITS);
#ifdef USE_PORTD
Serial.write(logicdata[i] >> 2);
#else
Serial.write(logicdata[i]);
#endif
@@ -665,8 +656,8 @@ void captureMilli() {
}
}
for (i = 0 ; i < readCount; i++) {
#ifdef SHIFTBITS
Serial.write(logicdata[i] >> SHIFTBITS);
#ifdef USE_PORTD
Serial.write(logicdata[i] >> 2);
#else
Serial.write(logicdata[i]);
#endif
@@ -859,8 +850,8 @@ void triggerMicro() {
if (logicIndex >= readCount) {
logicIndex = 0;
}
#ifdef SHIFTBITS
Serial.write(logicdata[logicIndex++] >> SHIFTBITS);
#ifdef USE_PORTD
Serial.write(logicdata[logicIndex++] >> 2);
#else
Serial.write(logicdata[logicIndex++]);
#endif
@@ -906,8 +897,6 @@ void get_metadata() {
Serial.write('A');
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
Serial.write('M');
#elif defined(__AVR_ATmega32U4__)
Serial.write('L');
#endif /* Mega */
Serial.write('v');
Serial.write('0');
@@ -918,7 +907,7 @@ void get_metadata() {
Serial.write('0');
Serial.write('.');
Serial.write('1');
Serial.write('2');
Serial.write('1');
Serial.write((uint8_t)0x00);
/* sample memory */
@@ -929,10 +918,6 @@ void get_metadata() {
/* 7168 bytes */
Serial.write((uint8_t)0x1C);
Serial.write((uint8_t)0x00);
#elif defined(__AVR_ATmega32U4__)
/* 1024 bytes */
Serial.write((uint8_t)0x04);
Serial.write((uint8_t)0x00);
#elif defined(__AVR_ATmega328P__)
/* 1024 bytes */
Serial.write((uint8_t)0x04);
@@ -952,15 +937,15 @@ void get_metadata() {
/* number of probes (6 by default on Arduino, 8 on Mega) */
Serial.write((uint8_t)0x40);
#ifdef CHAN7
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
Serial.write((uint8_t)0x08);
#elif CHAN6
Serial.write((uint8_t)0x07);
#elif CHAN5
#else
#ifdef CHAN5
Serial.write((uint8_t)0x06);
#else
Serial.write((uint8_t)0x05);
#endif
#endif /* CHAN5 */
#endif /* Mega */
/* protocol version (2) */
Serial.write((uint8_t)0x41);
@@ -1023,8 +1008,8 @@ void debugdump() {
Serial.print("\r\n");
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
#ifdef SHIFTBITS
Serial.print(logicdata[i] >> SHIFTBITS, HEX);
#ifdef USE_PORTD
Serial.print(logicdata[i] >> 2, HEX);
#else
Serial.print(logicdata[i], HEX);
#endif
@@ -1048,5 +1033,3 @@ void debugdump() {

View File

@@ -2,7 +2,7 @@
*
* SUMP Protocol Implementation for Arduino boards.
*
* Copyright (c) 2011,2012,2013,2014 Andrew Gillham
* Copyright (c) 2011,2012,2013 Andrew Gillham
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1154,7 +1154,7 @@ void captureInline2mhz() {
INLINE_NOP;
logicdata[531] = CHANPIN;
INLINE_NOP;
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#if defined(__AVR_ATmega328P__)
logicdata[532] = CHANPIN;
INLINE_NOP;
logicdata[533] = CHANPIN;
@@ -2139,8 +2139,7 @@ void captureInline2mhz() {
INLINE_NOP;
logicdata[1023] = CHANPIN;
INLINE_NOP;
#endif
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
logicdata[1024] = CHANPIN;
INLINE_NOP;
logicdata[1025] = CHANPIN;

View File

@@ -2,7 +2,7 @@
*
* SUMP Protocol Implementation for Arduino boards.
*
* Copyright (c) 2011,2012,2013,2014 Andrew Gillham
* Copyright (c) 2011,2012,2013 Andrew Gillham
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1154,7 +1154,7 @@ void captureInline4mhz() {
INLINE_NOP;
logicdata[531] = CHANPIN;
INLINE_NOP;
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#if defined(__AVR_ATmega328P__)
logicdata[532] = CHANPIN;
INLINE_NOP;
logicdata[533] = CHANPIN;
@@ -2139,8 +2139,7 @@ void captureInline4mhz() {
INLINE_NOP;
logicdata[1023] = CHANPIN;
INLINE_NOP;
#endif
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
logicdata[1024] = CHANPIN;
INLINE_NOP;
logicdata[1025] = CHANPIN;