There will be several posts about using the cheapest MCU board from China. So called Bluepill- PCB containing STM32F103C8T6 microcontroller, USB connector and some small elements. For a few bucks/euros we have upto 72MHz CPU, 64Kb of ROM and up to 20kb of RAM. Up to 100 millions instructions on one chip.
As all ARM chips it needs quite complicated initialization code and peripheral configuration. And there are tons of peripherals on the same pin. Manufacturer of the chip, STMicroelectronics, decided to make a graphical tool for chip configuration and init libraries. Also, they included some libraries for peripherals from simple GPIO to complex USB or fat file system. And all the stuff is compatible with generic GNU C (gcc) available free from ARM holdings and other sources. Same compiler is used in the well known learning system arduino, but without the use of quasi language extension. All software can be portable to any other platform and system. ’cause it is ISO/ANSI standard!
This tool is called STM32CubeMX (stand alone tool). First versions were extremely bad and full of bugs. After several years it became usable, but still there are errors, bugs and undocumented features.
This is an intro article, tutorial about how to build your first project with lots of pictures. Sorry, this blog version is not updated to the new width of the pictures. Will be fixed soon.
Due to a virus outbreak I was burning my time:
It is some type of fetish.
I found PCB from the classic 2600 JR. It was forcefully removed from the case maybe using a hammer. The PCB is bent, some parts torn out and missing switches.
PCB was cracked and several traces were broken. I repaired them, but the game didn’t start. Sometimes I noticed some video starting, but only for a few frames. I checked all connections using an oscilloscope and found that the CPU address pin (A7, maybe) is floating. I removed the chip and everything become clear:
Very interesting- the chip body is broken, but the crystal is OK. Only ONE leg disconnected.
The rest of the story is very simple: ordered some cheap from China, received a fake one, opened a dispute, and received money back. Then I ordered some other and the system started up.
I just only want to send notes to myself. Z80 CPU clock must be 5Vpp and pure TTL levels sometimes are too low for good and stable CPU work.
Even this old CPU is very stable at 5Vpp clock, meanwhile 3.3Vpp was too low. Some CPU versions are working fine, but some are very unstable. The 3V CPLD output was good only for the CMOS version, meanwhile NMOS was not working- only 2..3 CPU cycles.
This information is not written in all available datasheets.
I was testing various AM radios and noticed that I don’t have a proper AM source. The AM broadcasting station in my region is very scarce and weak. Also, I wanted more options for radio receiver testing.
I thought that the internet is full of simple AM modulator circuits, but…
Typical internet schematics are not ream AM. It only “some sort” of AM modulation, and, yes, radio receivers can decode sound from these circuits. Most circuits do “1″ and “2″ versions, but none was like real AM.
There is simple and good way to generate quite pure sine wave:
This circuit is not very simple, but results are quite fine: output is pure sine wave. From the other side, this schematics have some minuses: it is hard to change frequency. So this type of generator is not very useful for variable frequency devices.
For my purpose I am using this generator to modulate RF. Here are some oscilloscope shots of real world hardware:
AM modulation in it’s classic way:
P.S. This device uses dual polarity power supply.
After building ZX Spectrum clone in CPLD I ported hardware code to another project and this is a bit simpler, but it uses some mono LCD from old copy machine.
Now I used only one CPLD, but I added an additional SRAM chip. Now I don’t need any memory management (MMU)- the video part of the computer is completely “write only”. It is shadowed in the external SRAM chip and if the computer needs to read some data it does not get data from the video part of the computer. This makes design much easier to implement.
CPLD also monitors all IN/OUT operations and generates all specific video signals for LCD (it is four pixels at a time interface).
This is 320×240 pixel monochromatic screen, without any gray levels. So I can not emulate any colors using grayscale. For the border I used vertical stripes, but for the screen part is “only black and any other color is white” mode. So games are unusable. Also, moving parts are blurred.
All files to download:
Intel-Altera Quartus CPLD source code for ZX Spectrum LCD version.
Do not forget that regular Z80 need a 5Vpp clock for proper operation. I used a CMOS buffer for this.
Ant here is pinout for EDMMPU3BDF LCD:
5. pix CLK
6. Vcc, +5V
8. Vee, -25V
9. D3, pixel data
13. Vee, same as 8.
Sometimes I want to show how old 8 bit computers work for some n00bs. It is nice to load some games from tape, some from disk. But when I want to show more games, the best thing is cartridges. And not a single universal cartridge, but a pile of them. This looks more “expensive” and cool.
Another reason- cheap PCB and that I wanted to go in this way.
And the main reason for cartridges is speed- just put in and power on. I never liked this game.
I found an old ZX Spectrum clone made in Soviet Union in the 90′s. It was my computer, I wrote several programs on it and also, I wrote drivers for Epson printer on this hardware. This model has Soviet chip КР580ВВ55А (Intel i8255) and I used this port for the LPT interface and some custom hardware.
I powered it and without results- old crappy Soviet chips are dead. At least 3 chips were bad and the quality of PCB prevented me from full repair.
Good fellow donated my collection with a new item- Sharp PC-2500. The only big problem- this old computer had caustic batteries inside and they leaked. Alkaline used in the batteries has a very ugly feature- it can travel under conformal coating along copper traces. All this made this computer DOA.
In this picture, the computer is a bit working. Still missing some parts of the image, one keyboard key is not responsible and software freezes. It is possible that damage to PCB is not only eroded traces, but there is a side effect of CMOS technology- the resistance of the PCB is lowered and it may cause problems with high resistance CMOS circuitry. Any unclean spot in PCB has quite low resistance for low current signals. I was trying to wash parts of PCB, but it is paper based PCB and discoloration shows that alkaline salts are inside board material.