BusPirate / Bus_Pirate

Community driven firmware and hardware for Bus Pirate version 3 and 4
625 stars 131 forks source link

ADC doesn't work in repeat mode #145

Open PSLLSP opened 4 years ago

PSLLSP commented 4 years ago

Many commands support repeat mode. To wait 50ms, enter %:50.

HiZ>%
DELAY 1ms
HiZ>%:50
DELAY 50ms
HiZ>%:1000   
DELAY 1000ms
HiZ>%:30000   
DELAY 30000ms
HiZ>%:50000   
DELAY 50000ms

Well, the last one,%:50000, is another bug, it doesn't wait 50s...

To read 5 samples from AUX, enter @:5

HiZ>@
AUX INPUT/HI-Z, READ: 0
HiZ>@:5
AUX INPUT/HI-Z, READ: 0
AUX INPUT/HI-Z, READ: 0
AUX INPUT/HI-Z, READ: 0
AUX INPUT/HI-Z, READ: 0
AUX INPUT/HI-Z, READ: 0

This trick doesn't work for ADC:

HiZ>d
VOLTAGE PROBE: 0.00V
HiZ>d:5
VOLTAGE PROBE: 0.00V
Syntax error at char 2

ADC supports continuous mode, D, but I would like to have possibility to read exact number of samples (or an option to run continuous mode for predetermined time). When I need just few samples, up to about 300 samples, I can repeat d command several times, like ddddd to read 5 samples from ADC. Maybe I want more samples, 50000 samples d:50000, to run FFT analyse on measured data or to search for the shortest and the longest pulses. I CANNOT do that in an easy way (I can do that with BASIC scripting, the hard way...)

HiZ>ddddd
VOLTAGE PROBE: 0.00V
VOLTAGE PROBE: 0.00V
VOLTAGE PROBE: 0.00V
VOLTAGE PROBE: 0.00V
VOLTAGE PROBE: 0.00V

BTW, it is possible to repeat even commands that doesn't make sense, like a:5:

HiZ>a:5
AUX LOW
AUX LOW
AUX LOW
AUX LOW
AUX LOW

Is there any added value in command like this? I do not ask to disable this but to add such feature to d command... I think there are other commands that could have this feature, v to read inputs several times is good candidate (to monitor several inputs in the same time, very simple logical analyzer).

HiZ>v
Pinstates:
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     CLK     MOSI    CS      MISO
P       P       P       I       I       I       I       I       I       I
GND     0.00V   0.00V   0.00V   0.00V   L       L       L       L       L
HiZ>v:5
Pinstates:
1.(BR)  2.(RD)  3.(OR)  4.(YW)  5.(GN)  6.(BL)  7.(PU)  8.(GR)  9.(WT)  0.(Blk)
GND     3.3V    5.0V    ADC     VPU     AUX     CLK     MOSI    CS      MISO
P       P       P       I       I       I       I       I       I       I
GND     0.00V   0.00V   0.00V   0.00V   L       L       L       L       L
Syntax error at char 2

User macros cannot be repeated:

HiZ><1=dddddddddddddddddddd>
HiZ><0>
1. <dddddddddddddddddddd>
2. <>
3. <>
4. <>
5. <>
HiZ><1>:5

Syntax error at char 4
HiZ>dddddddddddddddddddd

One curiosity about timer. Following command should activate AUX output for 30 seconds. I have LED connected to AUX output and I measure with stopwatch how accurate is Bus Pirate timing. I measure about 38 seconds, that is 25% more!

HiZ>aA%:30000a
AUX LOW
AUX HIGH
DELAY 30000ms
AUX LOW

Note. My BusPirate 3b is from eBay, small cute box with 2 LEDs...

HiZ>i
Bus Pirate v3.b clone w/different PIC
Firmware v6.3-beta1 r2151  Bootloader v4.4
DEVID:0x044F REVID:0x3003 (24FJ64GA004 A3)
http://dangerousprototypes.com