From 528d653bdef957121200364aa116aa1587fefa19 Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 10 Jan 2019 14:31:20 +0900 Subject: Decoding and comma triggering works --- fw/Scope.ipynb | 32 ++++++++++++++------------------ fw/adc.c | 42 +++++++++++++++++++++++++++++++++++++++++- fw/scope.gdb | 12 ++++++++++++ 3 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 fw/scope.gdb (limited to 'fw') diff --git a/fw/Scope.ipynb b/fw/Scope.ipynb index 966c83c..33596a0 100644 --- a/fw/Scope.ipynb +++ b/fw/Scope.ipynb @@ -2,18 +2,19 @@ "cells": [ { "cell_type": "code", - "execution_count": 6, + "execution_count": 208, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "%matplotlib notebook\n", - "import struct" + "import struct\n", + "import math" ] }, { "cell_type": "code", - "execution_count": 119, + "execution_count": 207, "metadata": {}, "outputs": [], "source": [ @@ -22,27 +23,21 @@ " raw_data = f.read()\n", " data = struct.unpack(f'<{len(raw_data)//2}{\"h\" if signed else \"H\"}', raw_data)\n", " \n", - " print(''.join(str(x) for x in data[offx:][:100]))\n", - " fig, axs = plt.subplots(channels, 1, figsize=(10, 5))\n", - " for i, ax in enumerate(axs):\n", - " ax.plot(data[offx:][:end][i::channels])\n", - " ax.grid()" + " fig, axs = plt.subplots(channels, 1, squeeze=False, sharex=True, figsize=(10, 5))\n", + " for i, ax in enumerate(axs.flatten()):\n", + " ax.plot([math.nan if x==-255 else x for x in data[offx:][:end][i::channels]])\n", + " ax.grid()\n", + " \n", + " return data" ] }, { "cell_type": "code", - "execution_count": 121, + "execution_count": 213, "metadata": { "scrolled": false }, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "61515991715159978151599491515997101515997111515991121515994131515997141515991050-5345150-5361250-5358350-5351450-5348550-53616150-53547150-53488150-53549150-5361051599115159912515991351598845159915515988\n" - ] - }, { "data": { "application/javascript": [ @@ -826,7 +821,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -837,7 +832,8 @@ } ], "source": [ - "plot_data(offx=4, signed=True, channels=4)" + "data = plot_data(offx=4, signed=True, channels=1)\n", + "#print(''.join(str(x) for x in data[4:][3::4]))" ] }, { diff --git a/fw/adc.c b/fw/adc.c index 117377b..06cf027 100644 --- a/fw/adc.c +++ b/fw/adc.c @@ -258,14 +258,16 @@ void DMA1_Channel1_IRQHandler(void) { // st.detector.debounce_ctr--; //} + /* if (debug_buf_pos < NCH || debug_buf_pos >= sizeof(adc_buf)/sizeof(adc_buf[0])) { debug_buf_pos = NCH; gdb_dump(); } adc_buf[debug_buf_pos++] = st.detector.len_ctr; adc_buf[debug_buf_pos++] = st.detector.committed_len_ctr; - adc_buf[debug_buf_pos++] = st.detector.bit; adc_buf[debug_buf_pos++] = diff; + int foo = 0; + */ if (st.detector.len_ctr >= st.detector.committed_len_ctr) { /* @@ -274,8 +276,41 @@ void DMA1_Channel1_IRQHandler(void) { gdb_dump(); } adc_buf[debug_buf_pos++] = st.detector.bit; + int foo = st.detector.symbol; + if (foo < 0 && foo != K28_1) + foo = 0; + adc_buf[debug_buf_pos++] = foo; */ + if (st.detector.symbol != -DECODING_IN_PROGRESS) { + static int trig = 0; + if (st.detector.symbol == -K28_1) { + if (trig == 10) { + gdb_dump(); + for (int i=0; i= sizeof(adc_buf)/sizeof(adc_buf[0])) { + debug_buf_pos = 0; + } + if (debug_buf_pos >= NCH) { + adc_buf[debug_buf_pos++] = st.detector.symbol; + } + } + /* + if (debug_buf_pos < NCH || debug_buf_pos >= sizeof(adc_buf)/sizeof(adc_buf[0])) { + debug_buf_pos = NCH; + gdb_dump(); + } + adc_buf[debug_buf_pos++] = st.detector.bit; + */ + //foo = st.detector.bit ? 1 : -1; + st.detector.committed_len_ctr += st.detector.base_interval_cycles; st.detector.symbol = xfr_8b10b_feed_bit((struct state_8b10b_dec *)&st.detector.rx8b10b, st.detector.bit); /* @@ -285,9 +320,14 @@ void DMA1_Channel1_IRQHandler(void) { gdb_dump(); } adc_buf[debug_buf_pos++] = st.detector.symbol; + adc_buf[debug_buf_pos++] = st.detector.symbol == -DECODING_ERROR; + adc_buf[debug_buf_pos++] = st.detector.symbol == -K28_1; + adc_buf[debug_buf_pos++] = 0; } */ } + + //adc_buf[debug_buf_pos++] = foo; st.detector.len_ctr++; st.ovs_count = 0; diff --git a/fw/scope.gdb b/fw/scope.gdb new file mode 100644 index 0000000..8e4bb99 --- /dev/null +++ b/fw/scope.gdb @@ -0,0 +1,12 @@ +target remote localhost:3334 +set pagination off +file main.elf +load + +break DMA1_Channel1_IRQHandler +command 1 + dump binary value /tmp/scope_dump.bin adc_buf + continue +end + +continue -- cgit