Skip to content

Instantly share code, notes, and snippets.

@wohali
Last active June 13, 2024 08:59
Show Gist options
  • Save wohali/83d778170415deb10b737f251e023716 to your computer and use it in GitHub Desktop.
Save wohali/83d778170415deb10b737f251e023716 to your computer and use it in GitHub Desktop.
Multi-Function Tester TC1 flashing

Updating U4

  1. Unscrew the case via the 4 screws on the back.

  2. Desolder the positive lead of the rechargeable battery. This is necessary because the bootloader of U4 is only present immediately after power-on.

  3. Configure Tigard (or other USB-TTL device) as follows:

    1. VTGT switch to 3V3
    2. TX to P1 (left side of U4, clearly marked
    3. RX to P2 (just above P1)
    4. GND to GND (just below P1, unmarked)
    5. Prep VTGT to connect to VTGT (just above P2, unmarked, trace goes to pin 2 of U4)
  4. Connect Tigard to Linux PC. 3 LEDs on Tigard should light. Confirm via dmesg serial port for Tigard (probably /dev/ttyUSB0)

  5. Install stcgal from repo:

    git clone https://github.com/grigorig/stcgal
    ./setup.py build
    sudo ./setup.py install
    cd ..
    
  6. Download U4 firmware: wget https://raw.githubusercontent.com/atar-axis/tc1-u4/master/tc1-u4/Objects/u4.hex

  7. Verify stcgal can talk to your chip. Run the command below, and when it says Waiting for MCU, please cycle power, connect VTGT to 3V3 on the board. You should get an output like this (frequency may vary):

    $ ./stcgal.py -P stc15 -p /dev/ttyUSB0
    Waiting for MCU, please cycle power: done
    Target model:
      Name: STC15W104
      Magic: F2A4
      Code flash: 4.0 KB
      EEPROM flash: 1.0 KB
    Target frequency: 33.023 MHz
    Target BSL version: 7.2.5T
    Target wakeup frequency: 36.425 KHz
    Target options:
      reset_pin_enabled=False
      clock_source=internal
      clock_gain=high
      watchdog_por_enabled=False
      watchdog_stop_idle=True
      watchdog_prescale=256
      low_voltage_reset=True
      low_voltage_threshold=3
      eeprom_lvd_inhibit=True
      eeprom_erase_enabled=False
      bsl_pindetect_enabled=False
      por_reset_delay=long
      rstout_por_state=high
      uart2_passthrough=False
      uart2_pin_mode=normal
      cpu_core_voltage=unknown
    Disconnected!
    
  8. Disconnect VTGT, run stcgal -P stc15 -P /dev/ttyUSB0 -t 12000 ./u4.hex, and re-power VTGT. After the initial preamble the output should look like this as it runs (progress bar not displayed, takes about 15s):

    Loading flash: 3719 bytes (Intel HEX)
    Trimming frequency: 11.987 MHz
    Switching to 19200 baud: done
    Erasing flash: done
    Writing flash: 4160 Bytes [00:04, 1031.41 Bytes/s] 
    Finishing write: done
    Setting options: done
    Target UID: F2A401B15C3A03
    Disconnected!
    
  9. Unpower VTGT, repeat identification run, and re-power VTGT to verify it has been programmed right:

    $ ./stcgal.py -P stc15 -p /dev/ttyUSB0
    Waiting for MCU, please cycle power: done
    Target model:
      Name: STC15W104
      Magic: F2A4
      Code flash: 4.0 KB
      EEPROM flash: 1.0 KB
    Target frequency: 11.987 MHz
    Target BSL version: 7.2.5T
    Target wakeup frequency: 36.425 KHz
    Target options:
      reset_pin_enabled=False
      clock_source=internal
      clock_gain=high
      watchdog_por_enabled=False
      watchdog_stop_idle=True
      watchdog_prescale=256
      low_voltage_reset=True
      low_voltage_threshold=3
      eeprom_lvd_inhibit=True
      eeprom_erase_enabled=False
      bsl_pindetect_enabled=False
      por_reset_delay=long
      rstout_por_state=high
      uart2_passthrough=False
      uart2_pin_mode=normal
      cpu_core_voltage=unknown
    Disconnected!
    

Updating U1

  1. Read https://raw.githubusercontent.com/madires/Transistortester-Warehouse/master/Documentation/English/ctester-1.43m.pdf (or the correct version) and double-check all settings for TC1.

  2. Pull the latest 'm' firmware from https://github.com/madires/Transistortester-Warehouse/tree/master/Firmware/m-firmware (latest as of this writing: 1.43) & unpack.

  3. Make these changes to Makefile:

    MCU = atmega324p    # check chip model on your board to be sure, might be 640/644/644P/644PA
    FREQ = 16           # check crystal on your board to be sure
    PARTNO = m324pa     # again, check your board
    PROGRAMMER = tigard
    PORT = usb
    OPTIONS = -C +tigard.conf
      EFUSE = -U efuse:w:0xfd:m    # this is on line 313, inside of ifeq (${FAMILY},atmega328_324_640)
  4. Make these changes to config.h:

    #define HW_REF25                 // uncomment
    #define UREF_25           2495   // reconnect battery, push button, and
                                     // check value @ U2 pin 1 (trace connects to U7 footprint) 
                                     // with best DVM you have, then disconnect battery again
    #define HW_ZENER                 // uncomment
    #define ZENER_DIVIDER_CUSTOM     // uncomment
    #define ZENER_R1         100000
    #define ZENER_R2         12000
    #define ZENER_UNSWITCHED         // uncomment
    #define HW_PROBE_ZENER           // uncomment
    #define ZENER_VOLTAGE_MIN     1000      /* min. voltage in mV */
    #define ZENER_VOLTAGE_MAX     33000     /* max. voltage in mV */ // ADJUST after fully programmed, so that zener is not autodetected on initial startup
    #define HW_IR_RECEIVER           // uncomment only if you're going to use it
    #define HW_ADJUST_CAP            // uncomment
    #define SW_POWER_OFF
    //////// below are all optional (but some disabling may be mandatory for smaller chips)
    //#define SW_IR_RECEIVER         // requires HW mod, saves flash if off
    //#define SW_SQUAREWAVE          // requires HW mod, saves flash if off
    //#define SW_PWM_SIMPLE          // requires HW mod, saves flash if off
    //#define HW_IR_RECEIVER         // leave commented if you want any of these options:
        #define SW_R_E96_CC           /* E96 1% tolerance, color-code */
        #define SW_C_E12_T            /* E12 10% tolerance, text */
        #define SW_L_E12_T            /* E12 10% tolerance, text */
        #define SW_HFE_CURRENT
        #define SW_MONITOR_R          /* just R */
        #define SW_MONITOR_C          /* just C plus ESR */
    //////// these will fit with HW_IR_RECEIVER still on:
    #define SW_ESR_TOOL
    #define SW_CAP_LEAKAGE
    #define SW_REVERSE_HFE
    //////// Below are optional UI/UX changes
    #define UI_AUTOHOLD
    #define UI_HEX_UPPERCASE
    #define POWER_OFF_TIMEOUT     60
    #define UI_COLORED_TITLES
    #define UI_COLORED_CURSOR
  5. Edit config_644.h. remove the #if 0 around the ST7735 block, and re-add the #if 0 around the ILI9342 block. Then, modify all these lines:

    #define LCD_RES          PB4            /* port pin used for /RESX (optional) */
    //#define LCD_CS           PB4            /* port pin used for /CSX (optional) */
    #define LCD_DC           PB5            /* port pin used for D/CX */
    #define LCD_SCL          PB7            /* port pin used for SCL */
    #define LCD_SDA          PB6            /* port pin used for SDA */
    #define LCD_OFFSET_X     2               /* enable x offset of 2 or 4 dots */
    #define LCD_OFFSET_Y     1               /* enable y offset of 1 or 2 dots */
    #define LCD_FLIP_X                      /* enable horizontal flip */
    //#define LCD_FLIP_Y                      /* enable vertical flip */
    #define LCD_LATE_ON                     /* turn on LCD after clearing it */
    //#define SPI_HARDWARE                    /* hardware SPI */
    #define SPI_BITBANG
    #define SPI_PORT   LCD_PORT             /*SPI port data register*/
    #define SPI_DDR    LCD_DDR              /*SPI port data direction register*/
    #define SPI_SCK    LCD_SCL              /*port pin used for SCK*/
    #define SPI_MOSI   LCD_SDA              /*port pin used for MOSI*/
    //
    // then farther down
    //
    #define TP_ZENER         PA4       /* test pin for 10:1 voltage divider */
    #define TP_REF           PA3       /* test pin for 2.5V reference and relay */
    #define TP_BAT           PA5       /* test pin for battery (4:1 voltage divider) */
    #define TP_CAP           PA7       /* test pin for self-adjustment cap */
    //
    #define R_PORT           PORTC     /* port data register */
    #define R_DDR            DDRC      /* port data direction register */
    #define R_RL_1           PC0       /* Rl (680R) for test pin #1 */
    #define R_RH_1           PC1       /* Rh (470k) for test pin #1 */
    #define R_RL_2           PC2       /* Rl (680R) for test pin #2 */
    #define R_RH_2           PC3       /* Rh (470k) for test pin #2 */
    #define R_RL_3           PC4       /* Rl (680R) for test pin #3 */
    #define R_RH_3           PC5       /* Rh (470k) for test pin #3 */
    //
    #define POWER_PORT       PORTD     /* port data register */
    #define POWER_DDR        DDRD      /* port data direction register */
    #define POWER_CTRL       PD2       /* control pin (1: on / 0: off) */
    //
    #define BUTTON_PORT      PORTD     /* port data register */
    #define BUTTON_DDR       DDRD      /* port data direction register */
    #define BUTTON_PIN       PIND      /* port input pins register */
    #define TEST_BUTTON      PD1       /* test/start push button (low active) */
    ###
    #define IR_PORT          PORTD     /* port data register */
    #define IR_DDR           DDRD      /* port data direction register */
    #define IR_PIN           PIND      /* port input pins register */
    #define IR_DATA          PD3       /* data signal */
    //
    #define ADJUST_PORT      PORTC     /* port data register */
    #define ADJUST_DDR       DDRC      /* port data direction register */
    #define ADJUST_RH        PC6       /* Rh (470k) for fixed cap */
  6. Edit colors.h if you want to change the default title and cursor colours. I like:

    #define COLOR_TITLE           COLOR_STEEL_BLUE
    #define COLOR_CURSOR          COLOR_STEEL_BLUE
  7. Create file called tigard.conf with the following contents:

    programmer
      parent "avrftdi"
      id = "tigard";
      desc = "Tigard interface board";
      usbdev = "B";
      sck = 0;
      mosi = 1;
      miso = 2;
      reset = 5;
    ;
    
  8. apt install -y gcc-avr avr-libc avrdude

  9. make and make sure all percentages (Program, Data, EEPROM) are < 100%. If not, disable some features and make again.

  10. Disconnect Tigard from USB. Set Tigard VTGT to 5V, then connect tigard as follows at J4, diagram is from underside of board (not LCD side)

    SRST  TCK   MISO
    GND   MOSI  VTGT
    
  11. make upload - if this fails, disable more features, make, and make upload again.

  12. make fuses

  13. Reconnect the battery, connect a micro-USB power source, and test by:

  14. Turn it on (press Start once)

  15. After the first detect, double-press Start to open the menu

  16. Short-press until you reach the Test option, then long-press

  17. Connect all 3 probes together (1, 2, 3) and let it complete 4 tests

  18. Then remove short circuit and let it finish

  19. If test succeeds, run the Adjustment (same process) and then run Save to slot 1. This will get loaded on every power cycle.

You're done!

References

https://raw.githubusercontent.com/madires/Transistortester-Warehouse/master/Documentation/English/ctester-1.43m.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment