-
The Microcontroller
10/13/2019 at 20:38 • 0 commentsThe hardware is rather simplistic. It consists mainly of 4 LEDs and tactile switches surrounding the MCU. Lets have a look at the chip itself.
The chip itself is part of chinese STCmicro line of 8051 derivative MCUs. It sports a 1T architecture compared to crusty old 12T architecture of the original one, meaning it's much more efficient (though no 8051 is really a 1T machine anyway, so don't expect it to really be 12 times faster).
The MCU comes in DIP8 and SOP8, and should be really cheap - I got mine for 0.27$ for piece in quantity of 10 from aliexpress (DIP8), and I believe you can find it even cheaper. It has 4kB of flash, only 128 bytes of ram without XRAM, 2 timers (the traditional T0 timer but no T1 timer, but rather T2 timer which can't count external interrupt events in hardware), and not even UART, presumably (we might tackle it later).
It also has an internal oscillator which can be calibrated quite accurately to arbitrary values, internal clock dividers and other power control goodies absent from the original. It's brothers look pretty much the same:
It's not much compared to other MCUs in the market, but it's more than plenty to make a simon game - Consider that the original one was implemented on TMS1000 4bit microcontrollers which had 64 nibbles (not bytes!) of ram, 1kB of flash, single level stack and no interrupts at all, and did it successfully.
One sweet thing about most STC micros is that you don't need no special programmer. The programming is made using simple UART. The only thing you need is one of these cheap USB to TTL serial adapters, which you seriously own if you want to do real shit with microcontrollers:
This should be connected to the chip according to the datasheet, as presented below. P3.0 is UART RX output of standard 8051, and so P3.1 is the TX. This makes me suspect even further that the UART peripheral is really there.
STC has a utility called STC-ISP which takes care of it for you. It's quite ugly and lots of chinese script can't be parsed in my computer, making parts of the GUI a real mess. It contains many tabs for random stuff, but the only tab that's going to interest us is the code buffer (and maybe one day the EEPROM buffer).
To download the code you should open your binary with 'open code file', take the MCU off, press download and ONLY THEN turn it on. It feels backwards at first, but it's actually good, as the bootloader doesn't need to make boot from power off take so long as bootloaders tend to do.
And it worked! Woohoo!
A better and more thorough overlook for STC can be found on Jay Carlson's website. It's part of a very thorough comparison of simple microcontrollers he made, which I very liked and can recommend to take a look at.
-
Why?
10/10/2019 at 01:00 • 0 commentsI have a few educational motivations for this project.
First, I wanted to use 8051 assembly and get the feel of bare metal coding.
Second, I wanted to use a contemporary, open source assembler, thus the only feasible option I found was using SDAS, from the SDCC collection of open-source tools.
Additionally, I also wanted to try the cute STC15F104W microcontroller, which is a 8051 derivative.
"Well", thought I, "why wouldn't I do it all simultaneously?". Inspired by some other 8-pin microcontroller simon designes, most notably this excellent one, I went on to building my own version, as it seemed to me as a good project to achieve the educational targets I have marked to myself.
Soon enough I have noticed that there is very little information and examples (in english, at least) about the STC chip, and almost no information at all for using SDAS. These made it a little painful to dive into this project.
Thus another target was added to this list - documenting the whole work with the assembler and the STC chip, thinking that it would be nice to finally have some resources in the web for random folks like me who think about working with these tools.
This is going to be a fun and frustrating journey - let's get going :)