Friday, May 14, 2021

Program Blue Pill with CKS32F103C8T6 using UART

 I needed a Blue Pill for a project. Got a few on ebay, but I couldn't find genuine STM32 ones in Europe. So I got ones with the compatible CKS32F103C8T6 chip.

I have never programmed a Blue Pill of any kind, so I don't really know how it is supposed to work. Programming with ST's UART tool didn't work for me, it didn't like the identity of the board. I instead got success using stm32flash, which can be found here https://sourceforge.net/projects/stm32flash/ .

I used  some generic USB-to-UART cable, which identifies as being "Prolific USB-to-Serial". Make sure that the UART dongle works by doing a loop test.

To program the chip on the Blue Pill, follow these steps:

  1. On Blue Pill set jumper for"boot 0" to 1.
  2. Connect UART GND (black) to G on Blue Pill
    UART 5V (red) to 5V on Blue Pill
    UART RX (white) to A9 on Blue Pill
    UART TX (green) to A10 on Blue Pill
  3. From command line, run:
    stm32flash -g 0x8000000 -b 115200 -w gd32f1_generic_boot20_pc13.bin COM4
    where COM4 is whatever com-port the UART has attached to, and the bin-file is whatever bin-file you want to upload.
    There seems to be some problem with paths and stm32flash, so I run everything from the same folder.
  4. On Blue Pill set jumper for"boot 0" to 0.
  5. Push reset button on Blue Pill.
  6. Done! 

Tuesday, March 30, 2021

ABC80, Saving and loading programs using soundcard

As a cheap and quick way to get going, using an ABC80 (by Swedish Luxor), you can use a pc with a soundcard to save and load programs, like you normally would do using a tape station.


1 Cable

You need a cable with a 3.5mm audio, stereo plug in one end, and a 5 pin DIN in the other end. The cable should be wired like shown in the image:
 

Cable should be connected like this 

2 Audacity

I use Audacity as audio software on the PC. I'm sure there are plenty of other programs that are usable.
Set up audacity like in the images:
  • Mono sound
  • Set inputs and outputs so you hear output in a pair of headphones, and inputs so a mic gets picked up by the soundcard
  • Max levels on record and playback

 3 Save

  1. Enter a program in the ABC80. For example
    10 print "Hello world!"
  2. Insert 3.5mm audio plug into mic jack and DIN-connector in ABC80
  3. Start recording in audacity
  4. In the ABC80, enter:
    save cas
  5. Watch the waveform get recorded. 
  6. When the waveform ends, stop recording. 
  7. Delete the whitespace before and after the waveform.
  8. Save as .WAV-file.
Saving waveform in Audacity

4 Load

  1. Load wave file in audacity
  2. Insert 3.5 mm audio plug into headphone jack on PC and DIN-connector in ABC80.
  3. On ABC80, enter load cas
  4. Start playback in Audacity
  5. When the program has finished loading, ABC80 will give a new prompt or an error message
  6. list or run the program
Loading program from audio file in Audacity

Good Luck!