Improve pre-trigger sampling on below 500kHz sample rates.

The sample loop was not padded properly in the loop waiting for the
trigger to fire. As a result it was sampling at a much higher rate than
the post trigger sample rate.  I've added some delays and padded it out
a bit, it needs further measurement, but is usable now.
This commit is contained in:
Andrew Gillham
2012-02-27 14:36:09 -08:00
parent 3a6329775c
commit f51d0bbb96

View File

@@ -25,7 +25,7 @@
* (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.pde,v 1.17 2011-08-04 02:31:01 gillham Exp $
* $Id: logic_analyzer.ino,v 1.21 2012/02/27 20:19:44 gillham Exp $
*
*/
@@ -682,6 +682,12 @@ void triggerMicro() {
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 */
@@ -693,7 +699,10 @@ void triggerMicro() {
* This needs adjustment so that we have the right spacing between the
* before trigger samples and the after trigger samples.
*/
delayMicroseconds(delayTime);
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");
/* keep sampling for delayCount after trigger */
PORTD = B10000000; /* debug timing measurement */
@@ -884,3 +893,6 @@ void debugdump() {
#endif /* DEBUG */