• Stitching boards with paper clips

    01/11/2025 at 09:44 0 comments

    People who follow my display board projects know that I usually design them to be cascaded for more digits. They are connected in series using either Dupont pin sockets and pin headers, or just soldered jumpers as in the photo above. Neither is satisfactory as there is still flexure. I have considered using small aluminium straps and screws to hold the boards together stiffly using the corner holes. But I would have to look for aluminium strip of the right width and hacksaw small lengths off.

    Today I tried another idea, using reusable paper clips that were designed to hold multiple sheets of a document together. They are attached to a corner of the document stack with a special tool. It's a solution between standard paper clips and fold back paper clips.

    It works and I would also need to put some hot glue on the clips to prevent them from sliding off. However in future I will also need to design enough clearance so that the clip doesn't short PCB connections as the one on top in the picture almost does.

  • A buglet initialising the CH552

    01/05/2025 at 00:08 0 comments

    When I finally put the two boards described in Flashing the CH552 dev board from the command line to use I noticed that button actions were faster. Counter advance worked twice as fast. The no-activity timeout for exiting set mode was 32 seconds instead of 64. At boot-up the MCU runs at 24 MHz, but this can be set to 12 MHz for compatibility with the classic 8051. The tick timer which governs the speed of button actions depends on the clock speed.

    I thought I had taken care of this in the initialisation code, but to cut to the chase, here's the diff showing what I did wrong:

    $ git diff 227da07..67b402a
    diff --git a/227da07 b/67b402a
    index 227da07..67b402a 100644
    --- a/227da07
    +++ b/67b402a
    @@ -200,8 +200,7 @@ void main(void)
            // change the clock divisor to generate 12 MHz
            SAFE_MOD = 0x55;
            SAFE_MOD = 0xAA;
    -       CLOCK_CFG &= ~CLOCK_DIVISOR;
    -       CLOCK_CFG |= CLOCK_DIVISOR;
    +       CLOCK_CFG = (bOSC_EN_INT | CLOCK_DIVISOR);
            SAFE_MOD = 0x00;                // any value will do
     #ifdef DEBUG
     #else

    The clock configuration register is protected against accidental modification by a protocol. You have to write the values 0x55 and 0xAA to the SAFE_MOD register, make your change, then exit by writing anything to SAFE_MOD. The intention of the original code was to read the bits in the CLOCK_CFG register, except for the CLOCK_DIVISOR (bottom 3) bits, then write it back with those bits modified. You can see that the first line ought to be:

    CLOCK_CFG &= (0xF8 | ~CLOCK_DIVISOR);

    to preserve the top 5 bits.

    But I also fell foul of another restriction and that is modification mode only lasts for a limited number of clock cycles. More instructions and the changes don't take. That was probably what was happening, it timed out before CLOCK_CFG was changed. So I just went for a simple one line replacement and that fixed the double speed problem.

    BTW, I prefer to run the MCU at a lower clock rate rather than recalibrate the timer for a faster clock. It's more reliable at lower clock rates, and the MCU is idle most of the time anyway.

  • Recording Internet radio with a Raspberry Pi 2B

    01/04/2025 at 07:42 0 comments

    Internet radio is great, you can listen to stations all over the world. You may wish to save some programs. I have been doing this for a while from my Linux workhorse. I recently looked into doing this from an ancient Raspberry Pi 2B. It took a couple of battles with the DietPi distro and the mplayer packages, but it's done. Here are the articles I wrote in my technical blog: