mirror of
https://github.com/gillham/logic_analyzer.git
synced 2026-05-09 09:44:07 +03:00
Compare commits
22 Commits
agla_v0_12
...
0.17.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a226d516d | ||
|
|
ed0666863b | ||
|
|
739144d57e | ||
|
|
0b2651864e | ||
|
|
71b7c4790d | ||
|
|
016eabdc12 | ||
|
|
1cdc52febc | ||
|
|
a426e85f0d | ||
|
|
b919640c7e | ||
|
|
636df223a4 | ||
|
|
57b1f18900 | ||
|
|
4f7f86f6d4 | ||
|
|
bd1fbe504e | ||
|
|
cfacce1758 | ||
|
|
11b8b5bbda | ||
|
|
4233770315 | ||
|
|
1e3f0696af | ||
|
|
5fb67c666d | ||
|
|
9a065516e2 | ||
|
|
d0afee13d2 | ||
|
|
23fb253929 | ||
|
|
3128dc35f0 |
22
LICENSE
Normal file
22
LICENSE
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023 Andrew Gillham
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY ANDREW GILLHAM ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL ANDREW GILLHAM BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
37
Makefile
37
Makefile
@@ -1,19 +1,24 @@
|
|||||||
#
|
#
|
||||||
# Makefile for an Arduino based logic analyzer using the 'arduino-core'
|
# Makefile for an Arduino based logic analyzer using the arduino-cli
|
||||||
# package and makefiles.
|
|
||||||
#
|
#
|
||||||
# $Id: Makefile,v 1.3 2011-03-07 02:47:26 gillham Exp $
|
|
||||||
|
TARGET = logic_analyzer
|
||||||
|
FQBN = arduino:avr:diecimila
|
||||||
|
SERIAL = /dev/ttyUSB*
|
||||||
|
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo ""
|
||||||
|
@echo "---> run 'make build' to compile for Arduino Duemilanove"
|
||||||
|
@echo "---> run 'make upload' to upload to /dev/ttyUSB*"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
build:
|
||||||
|
arduino-cli compile --fqbn $(FQBN) $(TARGET)
|
||||||
|
|
||||||
|
upload:
|
||||||
|
arduino-cli upload --fqbn $(FQBN) --port $(SERIAL) $(TARGET)
|
||||||
|
|
||||||
|
#
|
||||||
|
# end-of-file
|
||||||
#
|
#
|
||||||
ARDUINO_DIR = /usr/share/arduino
|
|
||||||
|
|
||||||
TARGET = logic_analyzer
|
|
||||||
ARDUINO_LIBS =
|
|
||||||
|
|
||||||
MCU = atmega328p
|
|
||||||
F_CPU = 16000000
|
|
||||||
ARDUINO_PORT = /dev/ttyUSB*
|
|
||||||
AVRDUDE_ARD_BAUDRATE = 57600
|
|
||||||
AVRDUDE_ARD_PROGRAMMER = arduino
|
|
||||||
|
|
||||||
include /usr/share/arduino/Arduino.mk
|
|
||||||
|
|
||||||
|
|||||||
64
README
64
README
@@ -1,64 +0,0 @@
|
|||||||
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/
|
|
||||||
|
|
||||||
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, 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)
|
|
||||||
Channel Groups: 0 (zero) only
|
|
||||||
Recording Size:
|
|
||||||
ATmega168: 532 (or lower)
|
|
||||||
ATmega328: 1024 (or lower)
|
|
||||||
ATmega2560: 7168 (or lower)
|
|
||||||
Noise Filter: doesn't matter
|
|
||||||
RLE: disabled (unchecked)
|
|
||||||
|
|
||||||
Triggering is still a work in progress, but generally works for samples
|
|
||||||
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.12 September 6, 2013.
|
|
||||||
|
|
||||||
142
README.md
Normal file
142
README.md
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
SUMP compatible logic analyzer for Arduino
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
This Arduino sketch implements a SUMP protocol compatible logic analyzer.
|
||||||
|
This implementation is compatible with the standard SUMP client as well as
|
||||||
|
an alternative OLS client. More recently support has been added to Sigrok.
|
||||||
|
|
||||||
|
This logic analyzer for Arduino supports 6 channels consisting of digital
|
||||||
|
pins 8-13, which are the first 6 bits (0-5) of PORTB.
|
||||||
|
Arduino pin 13 / bit 5 is the Arduino LED, bits 6 & 7 are the crystal
|
||||||
|
oscillator pins. Comment out CHAN5 if you don't want to use the
|
||||||
|
LED pin for an input.
|
||||||
|
|
||||||
|
On the Arduino Mega board 8 channels are supported and 7k of samples.
|
||||||
|
Pins 22-29 (Port A) are used by default.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
You can use the GitHub 'Download ZIP' feature to get an installable "library"
|
||||||
|
for use with the Arduino IDE. Select 'Sketch -> Include Library -> Add .ZIP Libary'
|
||||||
|
from the Arduino IDE 2.x and select the zip file you downloaded from GitHub, then select open.
|
||||||
|
|
||||||
|
Once installed you can use the 'File -> Examples -> LogicAnalyzer' menu to find
|
||||||
|
different versions of the sketches. You might want to start with `logic_analyzer_sigrok`
|
||||||
|
and use PulseView.
|
||||||
|
|
||||||
|
Client Software
|
||||||
|
===============
|
||||||
|
|
||||||
|
Sigrok support via the 'ols' device configuration has been added. This
|
||||||
|
mostly involved returning the capture buffer in the reverse order.
|
||||||
|
|
||||||
|
Use the `logic_analyzer_sigrok` sketch. Since the OLS alternative client
|
||||||
|
mentioned below has some issues with newer Java versions, Sigrok is currently
|
||||||
|
the only practical way to use this logic analyzer. If you use an older machine
|
||||||
|
with an older operating system and older Java you can probably use the OLS client.
|
||||||
|
|
||||||
|
Sigrok support seems to work fairly well so I would currently recommend it for
|
||||||
|
anyone interested in trying this sketch.
|
||||||
|
|
||||||
|
Run PulseView like this on Linux: (I'll add Windows options after more testing)
|
||||||
|
```
|
||||||
|
PulseView --driver=ols:conn=/dev/ttyUSB0 --dont-scan
|
||||||
|
```
|
||||||
|
|
||||||
|
It may be necessary to exit and relaunch PulseView to get it to recognize the device.
|
||||||
|
An easy way to test the device is using the `sigrok-cli` utility. The command below
|
||||||
|
samples channel 2 at 1MHz. If you get a device not found error, but /dev/ttyUSB0 exists,
|
||||||
|
run this command a couple times and usually it will start working. Due to the way opening
|
||||||
|
the serial port resets the Arduino there are some issues/bugs to work out yet.
|
||||||
|
```
|
||||||
|
sigrok-cli --driver=ols:conn=/dev/ttyUSB0 --config samplerate=1Mhz --config pattern=External --samples 1024 --channels 2
|
||||||
|
```
|
||||||
|
|
||||||
|
The OLS alternative client hasn't had an official release recently so you will
|
||||||
|
need to compile it yourself.
|
||||||
|
|
||||||
|
Follow the build instructions here: https://github.com/jawi/ols
|
||||||
|
|
||||||
|
|
||||||
|
Older details on the OLS client is available at the project page:
|
||||||
|
https://lxtreme.nl/projects/ols/
|
||||||
|
|
||||||
|
Direct link to older releases of the OLS alternative client:
|
||||||
|
http://www.lxtreme.nl/ols/
|
||||||
|
|
||||||
|
The alternative client version is highly recommended. You can tried the older
|
||||||
|
release ols-0.9.7.2 but most likely need to build it yourself. Use "ols-0.9.7"
|
||||||
|
or newer for built-in device profiles.
|
||||||
|
|
||||||
|
To use this with the original or alternative SUMP clients,
|
||||||
|
use these settings:
|
||||||
|
```
|
||||||
|
Sampling rate: 4MHz (or lower) (no 2MHz on ATmega168)
|
||||||
|
Channel Groups: 0 (zero) only
|
||||||
|
Recording Size:
|
||||||
|
ATmega168: 532 (or lower)
|
||||||
|
ATmega328: 1024 (or lower)
|
||||||
|
ATmega2560: 7168 (or lower)
|
||||||
|
Noise Filter: doesn't matter
|
||||||
|
RLE: disabled (unchecked)
|
||||||
|
```
|
||||||
|
|
||||||
|
Using the Logic Analyzer
|
||||||
|
========================
|
||||||
|
Triggering is still a work in progress, but generally works for samples
|
||||||
|
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. Please provide a detailed bug report
|
||||||
|
if you file an issue.
|
||||||
|
|
||||||
|
Debugging
|
||||||
|
=========
|
||||||
|
|
||||||
|
You can uncomment the `#define DEBUG_MENU` line to add some diagnostic menu
|
||||||
|
options for capturing or dumping the capture buffer.
|
||||||
|
You can uncomment the `#define DEBUG` and `#define DEBUG_MENU` for a couple
|
||||||
|
extra menu options and logging of the received commands. The DEBUG option
|
||||||
|
is generally only useful for development, while the DEBUG_MENU option is
|
||||||
|
good for troubleshooting when the logic_analyzer sketch isn't working for you.
|
||||||
|
Both are disabled by default to conserve RAM for improved stability.
|
||||||
|
|
||||||
|
CLI compiling
|
||||||
|
=============
|
||||||
|
|
||||||
|
If you want to use the `arduino-cli` tool to compile this using the Makefile,
|
||||||
|
you'll need to install the tool first following instructions here:
|
||||||
|
https://arduino.github.io/arduino-cli/
|
||||||
|
|
||||||
|
Once installed you can simple type `make` and you should get some simple help:
|
||||||
|
```bash
|
||||||
|
$ make
|
||||||
|
---> run 'make build' to compile for Arduino Duemilanove
|
||||||
|
---> run 'make upload' to upload to /dev/ttyUSB*
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Other Notes
|
||||||
|
===========================================================================
|
||||||
|
```
|
||||||
|
NOTE: Starting with v0.11 you can 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 too big for an ATmega168's flash. The code
|
||||||
|
automatically skips the 2MHz code on ATmega168
|
||||||
|
|
||||||
|
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: 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. ]
|
||||||
|
```
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* SUMP Protocol Implementation for Arduino boards.
|
* SUMP Protocol Implementation for Arduino boards.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011,2012,2013 Andrew Gillham
|
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023 Andrew Gillham
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,26 +44,10 @@
|
|||||||
* Pins 22-29 (Port A) are used by default, you can change the 'CHANPIN' below
|
* Pins 22-29 (Port A) are used by default, you can change the 'CHANPIN' below
|
||||||
* if something else works better for you.
|
* 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,
|
* To use this with the original or alternative SUMP clients,
|
||||||
* use these settings:
|
* use these settings:
|
||||||
*
|
*
|
||||||
* Sampling rate: 4MHz (or lower)
|
* Sampling rate: 4MHz (or lower) (no 2MHz on ATmega168)
|
||||||
* Channel Groups: 0 (zero) only
|
* Channel Groups: 0 (zero) only
|
||||||
* Recording Size:
|
* Recording Size:
|
||||||
* ATmega168: 532 (or lower)
|
* ATmega168: 532 (or lower)
|
||||||
@@ -78,7 +62,7 @@
|
|||||||
* until after the trigger fires.
|
* until after the trigger fires.
|
||||||
* Please try it out and report back.
|
* Please try it out and report back.
|
||||||
*
|
*
|
||||||
* Release: v0.12 September 6, 2013.
|
* Release: v0.17 October 5, 2023.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -97,7 +81,9 @@ void blinkled(void);
|
|||||||
void get_metadata(void);
|
void get_metadata(void);
|
||||||
void debugprint(void);
|
void debugprint(void);
|
||||||
void debugdump(void);
|
void debugdump(void);
|
||||||
|
void prettydump(void);
|
||||||
|
void captureInline4mhz(void);
|
||||||
|
void captureInline2mhz(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should we use PORTD or PORTB? (default is PORTB)
|
* Should we use PORTD or PORTB? (default is PORTB)
|
||||||
@@ -170,6 +156,9 @@ void debugdump(void);
|
|||||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
#define DEBUG_CAPTURE_SIZE 7168
|
#define DEBUG_CAPTURE_SIZE 7168
|
||||||
#define CAPTURE_SIZE 7168
|
#define CAPTURE_SIZE 7168
|
||||||
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
|
#define DEBUG_CAPTURE_SIZE 2048
|
||||||
|
#define CAPTURE_SIZE 2048
|
||||||
#elif defined(__AVR_ATmega328P__)
|
#elif defined(__AVR_ATmega328P__)
|
||||||
#define DEBUG_CAPTURE_SIZE 1024
|
#define DEBUG_CAPTURE_SIZE 1024
|
||||||
#define CAPTURE_SIZE 1024
|
#define CAPTURE_SIZE 1024
|
||||||
@@ -186,8 +175,11 @@ void debugdump(void);
|
|||||||
#define DEBUG_ENABLE DDRD = DDRD | B10000000
|
#define DEBUG_ENABLE DDRD = DDRD | B10000000
|
||||||
#define DEBUG_ON PORTD = B10000000
|
#define DEBUG_ON PORTD = B10000000
|
||||||
#define DEBUG_OFF PORTD = B00000000
|
#define DEBUG_OFF PORTD = B00000000
|
||||||
#endif
|
#endif /* USE_PORTD */
|
||||||
#define DEBUG
|
|
||||||
|
//#define DEBUG_MENU
|
||||||
|
//#define DEBUG
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
|
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
|
||||||
#else
|
#else
|
||||||
@@ -279,10 +271,10 @@ void loop()
|
|||||||
|
|
||||||
if (Serial.available() > 0) {
|
if (Serial.available() > 0) {
|
||||||
cmdByte = Serial.read();
|
cmdByte = Serial.read();
|
||||||
switch(cmdByte) {
|
switch (cmdByte) {
|
||||||
case SUMP_RESET:
|
case SUMP_RESET:
|
||||||
/*
|
/*
|
||||||
* We don't do anything here as some unsupported extended commands have
|
* We don't do anything here as some unsupported extended commands have
|
||||||
* zero bytes and are mistaken as resets. This can trigger false resets
|
* zero bytes and are mistaken as resets. This can trigger false resets
|
||||||
* so we don't erase the data or do anything for a reset.
|
* so we don't erase the data or do anything for a reset.
|
||||||
*/
|
*/
|
||||||
@@ -296,14 +288,14 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
case SUMP_ARM:
|
case SUMP_ARM:
|
||||||
/*
|
/*
|
||||||
* Zero out any previous samples before arming.
|
* Zero out any previous samples before arming.
|
||||||
* Done here instead via reset due to spurious resets.
|
* Done here instead via reset due to spurious resets.
|
||||||
*/
|
*/
|
||||||
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
||||||
logicdata[i] = 0;
|
logicdata[i] = 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* depending on the sample rate we need to delay in microseconds
|
* depending on the sample rate we need to delay in microseconds
|
||||||
* or milliseconds. We can't do the complex trigger at 1MHz
|
* or milliseconds. We can't do the complex trigger at 1MHz
|
||||||
* so in that case (delayTime == 1 and triggers enabled) use
|
* so in that case (delayTime == 1 and triggers enabled) use
|
||||||
* captureMicro() instead of triggerMicro().
|
* captureMicro() instead of triggerMicro().
|
||||||
@@ -312,26 +304,28 @@ void loop()
|
|||||||
if (divider == 24) {
|
if (divider == 24) {
|
||||||
/* 4.0MHz */
|
/* 4.0MHz */
|
||||||
captureInline4mhz();
|
captureInline4mhz();
|
||||||
}
|
}
|
||||||
else if (divider == 49) {
|
else if (divider == 49) {
|
||||||
/* 2.0MHz */
|
/* 2.0MHz */
|
||||||
|
#if !defined(__AVR_ATmega168__)
|
||||||
captureInline2mhz();
|
captureInline2mhz();
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
else if (useMicro) {
|
else if (useMicro) {
|
||||||
if (trigger && (delayTime != 1)) {
|
if (trigger && (delayTime != 1)) {
|
||||||
triggerMicro();
|
triggerMicro();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
captureMicro();
|
captureMicro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
captureMilli();
|
captureMilli();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SUMP_TRIGGER_MASK:
|
case SUMP_TRIGGER_MASK:
|
||||||
/*
|
/*
|
||||||
* the trigger mask byte has a '1' for each enabled trigger so
|
* the trigger mask byte has a '1' for each enabled trigger so
|
||||||
* we can just use it directly as our trigger mask.
|
* we can just use it directly as our trigger mask.
|
||||||
*/
|
*/
|
||||||
getCmd();
|
getCmd();
|
||||||
@@ -343,7 +337,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
case SUMP_TRIGGER_VALUES:
|
case SUMP_TRIGGER_VALUES:
|
||||||
/*
|
/*
|
||||||
* trigger_values can be used directly as the value of each bit
|
* trigger_values can be used directly as the value of each bit
|
||||||
* defines whether we're looking for it to be high or low.
|
* defines whether we're looking for it to be high or low.
|
||||||
*/
|
*/
|
||||||
getCmd();
|
getCmd();
|
||||||
@@ -359,7 +353,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
case SUMP_SET_DIVIDER:
|
case SUMP_SET_DIVIDER:
|
||||||
/*
|
/*
|
||||||
* the shifting needs to be done on the 32bit unsigned long variable
|
* the shifting needs to be done on the 32bit unsigned long variable
|
||||||
* so that << 16 doesn't end up as zero.
|
* so that << 16 doesn't end up as zero.
|
||||||
*/
|
*/
|
||||||
getCmd();
|
getCmd();
|
||||||
@@ -372,7 +366,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
case SUMP_SET_READ_DELAY_COUNT:
|
case SUMP_SET_READ_DELAY_COUNT:
|
||||||
/*
|
/*
|
||||||
* this just sets up how many samples there should be before
|
* this just sets up how many samples there should be before
|
||||||
* and after the trigger fires. The readCount is total samples
|
* and after the trigger fires. The readCount is total samples
|
||||||
* to return and delayCount number of samples after the trigger.
|
* to return and delayCount number of samples after the trigger.
|
||||||
* this sets the buffer splits like 0/100, 25/75, 50/50
|
* this sets the buffer splits like 0/100, 25/75, 50/50
|
||||||
@@ -396,7 +390,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
case SUMP_GET_METADATA:
|
case SUMP_GET_METADATA:
|
||||||
/*
|
/*
|
||||||
* We return a description of our capabilities.
|
* We return a description of our capabilities.
|
||||||
* Check the function's comments below.
|
* Check the function's comments below.
|
||||||
*/
|
*/
|
||||||
get_metadata();
|
get_metadata();
|
||||||
@@ -404,37 +398,85 @@ void loop()
|
|||||||
case SUMP_SELF_TEST:
|
case SUMP_SELF_TEST:
|
||||||
/* ignored. */
|
/* ignored. */
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_MENU
|
||||||
/*
|
/*
|
||||||
* a couple of debug commands used during development.
|
* a couple of debug commands used during development.
|
||||||
*/
|
*/
|
||||||
|
case '?':
|
||||||
|
Serial.println("");
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.println("0 = clear cmd buffer");
|
||||||
|
Serial.println("1 = print cmd buffer");
|
||||||
|
#endif /* DEBUG */
|
||||||
|
Serial.println("2 = print data buffer");
|
||||||
|
Serial.println("3 = pretty print buffer");
|
||||||
|
Serial.println("4 = capture at 4MHz");
|
||||||
|
Serial.println("5 = capture at 1MHz");
|
||||||
|
Serial.println("6 = capture at 500KHz");
|
||||||
|
break;
|
||||||
|
#ifdef DEBUG
|
||||||
case '0':
|
case '0':
|
||||||
/*
|
/*
|
||||||
* This resets the debug buffer pointer, effectively clearing the
|
* This resets the debug buffer pointer, effectively clearing the
|
||||||
* previous commands out of the buffer. Clear the sample data as well.
|
* previous commands out of the buffer. Clear the sample data as well.
|
||||||
* Just send a '0' from the Arduino IDE's Serial Monitor.
|
* Just send a '0' from the Arduino IDE's Serial Monitor.
|
||||||
*/
|
*/
|
||||||
savecount=0;
|
savecount = 0;
|
||||||
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
|
||||||
logicdata[i] = 0;
|
logicdata[i] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
/*
|
/*
|
||||||
* This is used to see what commands were sent to the device.
|
* This is used to see what commands were sent to the device.
|
||||||
* you can use the Arduino serial monitor and send a '1' and get
|
* you can use the Arduino serial monitor and send a '1' and get
|
||||||
* a debug printout. useless except for development.
|
* a debug printout. useless except for development.
|
||||||
*/
|
*/
|
||||||
blinkled();
|
blinkled();
|
||||||
debugprint();
|
debugprint();
|
||||||
break;
|
break;
|
||||||
|
#endif /* DEBUG */
|
||||||
case '2':
|
case '2':
|
||||||
/*
|
/*
|
||||||
* This dumps the sample data to the serial port. Used for debugging.
|
* This dumps the sample data to the serial port.
|
||||||
*/
|
*/
|
||||||
debugdump();
|
debugdump();
|
||||||
break;
|
break;
|
||||||
#endif /* DEBUG */
|
case '3':
|
||||||
|
/*
|
||||||
|
* Prints a visual representation of the data buffer.
|
||||||
|
*/
|
||||||
|
prettydump();
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
/*
|
||||||
|
* This runs a sample capture at 4MHz.
|
||||||
|
*/
|
||||||
|
captureInline4mhz();
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("4MHz capture done.");
|
||||||
|
break;
|
||||||
|
case '5':
|
||||||
|
/*
|
||||||
|
* This runs a sample capture at 1MHz.
|
||||||
|
* delayTime = 1ms for 1MHz sampling.
|
||||||
|
*/
|
||||||
|
delayTime = 1;
|
||||||
|
captureMicro();
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("1MHz capture done.");
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
/*
|
||||||
|
* This runs a sample capture at 500KHz.
|
||||||
|
* delayTime = 2ms for 500KHz.
|
||||||
|
*/
|
||||||
|
delayTime = 2;
|
||||||
|
captureMicro();
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("500KHz capture done.");
|
||||||
|
break;
|
||||||
|
#endif /* DEBUG_MENU */
|
||||||
default:
|
default:
|
||||||
/* ignore any unrecognized bytes. */
|
/* ignore any unrecognized bytes. */
|
||||||
break;
|
break;
|
||||||
@@ -539,7 +581,7 @@ void captureMicro() {
|
|||||||
__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");
|
||||||
}
|
}
|
||||||
DEBUG_OFF; /* debug timing measurement */
|
DEBUG_OFF; /* debug timing measurement */
|
||||||
}
|
}
|
||||||
else if (delayTime == 2) {
|
else if (delayTime == 2) {
|
||||||
/*
|
/*
|
||||||
* 500KHz sample rate = 2 uS delay, still pretty fast so we pad this
|
* 500KHz sample rate = 2 uS delay, still pretty fast so we pad this
|
||||||
@@ -556,7 +598,7 @@ void captureMicro() {
|
|||||||
__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");
|
||||||
}
|
}
|
||||||
DEBUG_OFF; /* debug timing measurement */
|
DEBUG_OFF; /* debug timing measurement */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* not 1MHz or 500KHz; delayMicroseconds(delay - 1) works fine here
|
* not 1MHz or 500KHz; delayMicroseconds(delay - 1) works fine here
|
||||||
@@ -609,7 +651,7 @@ void captureMicro() {
|
|||||||
void captureMilli() {
|
void captureMilli() {
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
|
||||||
if(rleEnabled) {
|
if (rleEnabled) {
|
||||||
/*
|
/*
|
||||||
* very basic trigger, just like in captureMicros() above.
|
* very basic trigger, just like in captureMicros() above.
|
||||||
*/
|
*/
|
||||||
@@ -620,16 +662,16 @@ void captureMilli() {
|
|||||||
byte lastSample = 0;
|
byte lastSample = 0;
|
||||||
byte sampleCount = 0;
|
byte sampleCount = 0;
|
||||||
|
|
||||||
while(i < readCount) {
|
while (i < readCount) {
|
||||||
/*
|
/*
|
||||||
* Implementation of the RLE unlimited protocol: timings might be off a little
|
* Implementation of the RLE unlimited protocol: timings might be off a little
|
||||||
*/
|
*/
|
||||||
if(lastSample == (CHANPIN & B01111111) && sampleCount < 127) {
|
if (lastSample == (CHANPIN & B01111111) && sampleCount < 127) {
|
||||||
sampleCount++;
|
sampleCount++;
|
||||||
delay(delayTime);
|
delay(delayTime);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(sampleCount != 0) {
|
if (sampleCount != 0) {
|
||||||
logicdata[i] = B10000000 | sampleCount;
|
logicdata[i] = B10000000 | sampleCount;
|
||||||
sampleCount = 0;
|
sampleCount = 0;
|
||||||
i++;
|
i++;
|
||||||
@@ -641,7 +683,7 @@ void captureMilli() {
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* very basic trigger, just like in captureMicros() above.
|
* very basic trigger, just like in captureMicros() above.
|
||||||
@@ -670,7 +712,7 @@ void captureMilli() {
|
|||||||
* This works ok at 500KHz and lower sample rates. We don't have enough time
|
* This works ok at 500KHz and lower sample rates. We don't have enough time
|
||||||
* with a 16MHz clock to sample at 1MHz into the circular buffer. A 20MHz
|
* with a 16MHz clock to sample at 1MHz into the circular buffer. A 20MHz
|
||||||
* clock might be ok but all of the timings would have to be redone.
|
* clock might be ok but all of the timings would have to be redone.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void triggerMicro() {
|
void triggerMicro() {
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
@@ -717,7 +759,7 @@ void triggerMicro() {
|
|||||||
* click stop.
|
* click stop.
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (delayTime == 2) {
|
else if (delayTime == 2) {
|
||||||
/*
|
/*
|
||||||
* 500KHz case. We should be able to manage this in time.
|
* 500KHz case. We should be able to manage this in time.
|
||||||
@@ -746,7 +788,7 @@ void triggerMicro() {
|
|||||||
__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");
|
||||||
DEBUG_OFF; /* debug timing measurement */
|
DEBUG_OFF; /* debug timing measurement */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* One sample size delay. ends up being 2 uS combined with assignment
|
* One sample size delay. ends up being 2 uS combined with assignment
|
||||||
* below. This padding is so we have a consistent timing interval
|
* below. This padding is so we have a consistent timing interval
|
||||||
* between the trigger point and the subsequent samples.
|
* between the trigger point and the subsequent samples.
|
||||||
@@ -776,7 +818,7 @@ void triggerMicro() {
|
|||||||
}
|
}
|
||||||
DEBUG_OFF; /* debug timing measurement */
|
DEBUG_OFF; /* debug timing measurement */
|
||||||
delayMicroseconds(100);
|
delayMicroseconds(100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* Less than 500KHz case. This uses delayMicroseconds() and some padding
|
* Less than 500KHz case. This uses delayMicroseconds() and some padding
|
||||||
@@ -876,7 +918,7 @@ void setupDelay() {
|
|||||||
if (divider >= 1500000) {
|
if (divider >= 1500000) {
|
||||||
useMicro = 0;
|
useMicro = 0;
|
||||||
delayTime = (divider + 1) / 100000;
|
delayTime = (divider + 1) / 100000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
useMicro = 1;
|
useMicro = 1;
|
||||||
delayTime = (divider + 1) / 100;
|
delayTime = (divider + 1) / 100;
|
||||||
@@ -907,7 +949,7 @@ void get_metadata() {
|
|||||||
Serial.write('0');
|
Serial.write('0');
|
||||||
Serial.write('.');
|
Serial.write('.');
|
||||||
Serial.write('1');
|
Serial.write('1');
|
||||||
Serial.write('2');
|
Serial.write('7');
|
||||||
Serial.write((uint8_t)0x00);
|
Serial.write((uint8_t)0x00);
|
||||||
|
|
||||||
/* sample memory */
|
/* sample memory */
|
||||||
@@ -952,11 +994,11 @@ void get_metadata() {
|
|||||||
Serial.write((uint8_t)0x02);
|
Serial.write((uint8_t)0x02);
|
||||||
|
|
||||||
/* end of data */
|
/* end of data */
|
||||||
Serial.write((uint8_t)0x00);
|
Serial.write((uint8_t)0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is used by the '0' debug command to dump the contents of some
|
* This is used by the '1' debug command to dump the contents of some
|
||||||
* interesting variables and the debug buffer.
|
* interesting variables and the debug buffer.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -988,7 +1030,7 @@ void debugprint() {
|
|||||||
for (i = 0 ; i < savecount; i++) {
|
for (i = 0 ; i < savecount; i++) {
|
||||||
if (savebytes[i] == 0x20) {
|
if (savebytes[i] == 0x20) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.print(savebytes[i], HEX);
|
Serial.print(savebytes[i], HEX);
|
||||||
Serial.write(' ');
|
Serial.write(' ');
|
||||||
@@ -997,6 +1039,8 @@ void debugprint() {
|
|||||||
Serial.println("done...");
|
Serial.println("done...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* DEBUG */
|
||||||
|
#ifdef DEBUG_MENU
|
||||||
/*
|
/*
|
||||||
* This is used by the '2' debug command to dump the contents
|
* This is used by the '2' debug command to dump the contents
|
||||||
* of the sample buffer.
|
* of the sample buffer.
|
||||||
@@ -1021,7 +1065,37 @@ void debugdump() {
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
|
||||||
|
/*
|
||||||
|
* This is used by the '3' debugs command to dump the first 64 bytes
|
||||||
|
* of the sample buffer.
|
||||||
|
* It prints the data in a graphical representation.
|
||||||
|
*/
|
||||||
|
void prettydump() {
|
||||||
|
int i;
|
||||||
|
byte j;
|
||||||
|
byte k;
|
||||||
|
|
||||||
|
Serial.print("\r\n");
|
||||||
|
|
||||||
|
for (i = 0 ; i < 64; i++) {
|
||||||
|
#ifdef USE_PORTD
|
||||||
|
k = logicdata[i] >> 2;
|
||||||
|
#else
|
||||||
|
k = logicdata[i];
|
||||||
|
#endif
|
||||||
|
for (j = 0; j < 8; j++) {
|
||||||
|
if (k & 0x01)
|
||||||
|
Serial.print("| ");
|
||||||
|
else
|
||||||
|
Serial.print(" |");
|
||||||
|
k = k >> 1;
|
||||||
|
}
|
||||||
|
Serial.print("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* DEBUG_MENU */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* SUMP Protocol Implementation for Arduino boards.
|
* SUMP Protocol Implementation for Arduino boards.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011,2012,2013 Andrew Gillham
|
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023 Andrew Gillham
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* SUMP Protocol Implementation for Arduino boards.
|
* SUMP Protocol Implementation for Arduino boards.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011,2012,2013 Andrew Gillham
|
* Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023 Andrew Gillham
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
24
examples/logic_analyzer_leonardo/Makefile
Normal file
24
examples/logic_analyzer_leonardo/Makefile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#
|
||||||
|
# Makefile for an Arduino based logic analyzer using the arduino-cli
|
||||||
|
#
|
||||||
|
|
||||||
|
TARGET = logic_analyzer_leonardo
|
||||||
|
FQBN = arduino:avr:leonardo
|
||||||
|
SERIAL = /dev/ttyUSB*
|
||||||
|
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo ""
|
||||||
|
@echo "---> run 'make build' to compile for Arduino Leonardo"
|
||||||
|
@echo "---> run 'make upload' to upload to /dev/ttyUSB*"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
build:
|
||||||
|
arduino-cli compile --fqbn $(FQBN) $(TARGET)
|
||||||
|
|
||||||
|
upload:
|
||||||
|
arduino-cli upload --fqbn $(FQBN) --port $(SERIAL) $(TARGET)
|
||||||
|
|
||||||
|
#
|
||||||
|
# end-of-file
|
||||||
|
#
|
||||||
14456
examples/logic_analyzer_leonardo/logic_analyzer_inline_2mhz.ino
Normal file
14456
examples/logic_analyzer_leonardo/logic_analyzer_inline_2mhz.ino
Normal file
File diff suppressed because it is too large
Load Diff
14456
examples/logic_analyzer_leonardo/logic_analyzer_inline_4mhz.ino
Normal file
14456
examples/logic_analyzer_leonardo/logic_analyzer_inline_4mhz.ino
Normal file
File diff suppressed because it is too large
Load Diff
1052
examples/logic_analyzer_leonardo/logic_analyzer_leonardo.ino
Normal file
1052
examples/logic_analyzer_leonardo/logic_analyzer_leonardo.ino
Normal file
File diff suppressed because it is too large
Load Diff
14456
examples/logic_analyzer_sigrok/logic_analyzer_inline_2mhz.ino
Normal file
14456
examples/logic_analyzer_sigrok/logic_analyzer_inline_2mhz.ino
Normal file
File diff suppressed because it is too large
Load Diff
14456
examples/logic_analyzer_sigrok/logic_analyzer_inline_4mhz.ino
Normal file
14456
examples/logic_analyzer_sigrok/logic_analyzer_inline_4mhz.ino
Normal file
File diff suppressed because it is too large
Load Diff
1109
examples/logic_analyzer_sigrok/logic_analyzer_sigrok.ino
Normal file
1109
examples/logic_analyzer_sigrok/logic_analyzer_sigrok.ino
Normal file
File diff suppressed because it is too large
Load Diff
9
library.properties
Normal file
9
library.properties
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name=LogicAnalyzer
|
||||||
|
version=0.17.0
|
||||||
|
author=Andrew Gillham <gillham@roadsign.com>
|
||||||
|
maintainer=Andrew Gillham <gillham@roadsign.com>
|
||||||
|
sentence=A SUMP protocol compatible logic analyzer firmware
|
||||||
|
paragraph=These firmware sketches provide a 6 channel logic analyzer for use with the SUMP protocol based OLS clients. There is also a Sigrok compatible firmware using the OpenBench Logic Sniffer (ols) driver .
|
||||||
|
category=Signal Input/Output
|
||||||
|
url=https://github.com/gillham/logic_analyzer
|
||||||
|
architectures=avr
|
||||||
0
src/LogicAnalyzer.h
Normal file
0
src/LogicAnalyzer.h
Normal file
2
src/use_examples_for_logic_analyzer.h
Normal file
2
src/use_examples_for_logic_analyzer.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// This is a placeholder. Use File->Examples->LogicAnalyzer menu
|
||||||
|
// for the logic analyzer sketches.
|
||||||
Reference in New Issue
Block a user