Tuesday, August 23, 2011

Tiwaz' Day

See Wikipedia.

What to do today?
  • [ ] Start on 3-way replication of input-capture datapath with Darryl.  He can work on making the gelware changes, while I upgrade the firmware.  We should make sure to backup the present version of everything first.
  • [ ] (Lower priority.)  Try to get Nios CPU reset (FEDM user command CPU_RESET) working.  Need to learn more about the reset process, loading, etc.  It's possible that I just need to set those BSP options (e.g. the one to load .rwdata) and burn the design in EEPROM, in order to reinitialize the .rwdata properly from EEPROM on reset.
  • [ ] After CPU reset is working, consider adding a watchdog timer, so that if/when the firmware ever crashes, it will automatically reset.
  • [ ] Diagnose and fix the problem with occasional crashes when using STDIO library from ISR (for sending data either to stdout or to uart_0) when the system is handling high data throughput.  One strategy for addressing this:  Route all output through main-line code.  This will then require a couple of extra software line buffers, to pass lines of text from the ISR to the main execution context.  A concern, though:  Do I even have enough ROM space left to do this additional coding?  Also, the line buffers themselves will cut down somewhat on the amount of RAM available for the pulse buffers.
Darryl is here, and he defined the new icdp_ctrl register format:
  • Bit #0 - ICDP_RESET                (affects all ICDP channels simultaneously)
  • Bit #1 - ICDP_RUN_PAUSEn    (affects all ICDP channels simultaneously)
  • Bit #2 - ICDP_NEG_INPUT       (affects all ICDP channels simultaneously)
  • ICDP Channel #1:
    • Bit #4 - PUMP_DATA0    (PUMP_DATA for ICDP #1)
    • Bit #5 - BUF_FULL0        (BUF_FULL for ICDP #1)
    • Bit #6 - HAVE_DATA0    (HAVE_DATA for ICDP #1)
  • ICDP Channel #2:
    • Bit #7 - PUMP_DATA1    (PUMP_DATA for ICDP #2)
    • Bit #8 - BUF_FULL1        (BUF_FULL for ICDP #2)
    • Bit #9 - HAVE_DATA1    (HAVE_DATA for ICDP #2)
  • ICDP Channel #3:
    • Bit #10 - PUMP_DATA2    (PUMP_DATA for ICDP #3)
    • Bit #11 - BUF_FULL2        (BUF_FULL for ICDP #3)
    • Bit #12 - HAVE_DATA2    (HAVE_DATA for ICDP #3)
My notes on modifying the firmware (C code) to support multiple datapaths:
  • Change data structure in icdp_driver.h to include the PMT input channel #, and define more bitmasks.
  • Change the interrupt service routine to scan to see which PMT(s) raised their HAVE_DATA flags, then read from the appropriate one(s).
  • Change the routine that streams data to the server to include the PMT ID in the PULSE output message.
While coding, I realized the following changes to the register format made sense:
  • Global control bits:
    • Bit #0 - ICDP_RESET                (output; affects all ICDP channels simultaneously)
    • Bit #1 - ICDP_RUN_PAUSEn    (output; affects all ICDP channels simultaneously)
    • Bit #2 - ICDP_NEG_INPUT       (output; affects all ICDP channels simultaneously)
  • ICDP Channel Selector:
    • Bit #3 - ICDP_SEL0         (output; low-order bit of ICDP channel #, 0-3, to select)
    • Bit #4 - ICDP_SEL1         (output; high-order bit of ICDP channel #, 0-3, to select)
  • Bit #5 - ICDP_PUMP_DATA    (output; controls data pump for the currently selected channel)
  • Edge-capture interrupt flags (inputs):
    • Buffer-full flags:
      • Bit #6 - BUF_FULL0        (BUF_FULL for PMT #1)
      • Bit #7 - BUF_FULL1        (BUF_FULL for PMT #2)
      • Bit #8 - BUF_FULL2        (BUF_FULL for PMT #3)
    • Have-data flags:
      • Bit #9 - HAVE_DATA0    (HAVE_DATA for PMT #1)
      • Bit #10 - HAVE_DATA1    (HAVE_DATA for PMT #2)
      • Bit #11 - HAVE_DATA2    (HAVE_DATA for PMT #3)
This reformatting entailed two major changes:
  1. All edge-capture interrupt flags of a given type were put together, so that simply shifting the mask for channel #0 left by an amount given by the channel number is sufficient to compute the mask for a given channel number.
  2. A two-bit channel select control output was added, so that we would still only need 1 icdp_data PIO to read from any of the (up to 4) different PMT input channels.  This controls a MUX for the 32-bit data output words, plus a DEMUX to route the single PUMP_DATA control signal to the currently-selected datapath (we only want to pull data from one datapath at a time).

    No comments:

    Post a Comment