STC DIY Clock redux (STC15F204EA, STC15W404AS, STC15W408AS)
Firmware replacement for STC15F mcu-based DIY Clock Kit (available from banggood [see below for link], aliexpress, et al.) Uses sdcc to build and stcgal to flash firmware on to STC15F204EA (and STC15W408AS) series microcontroller.
link to Banggood product page for SKU 972289
gps
branch: https://github.com/zerog2k/stc_diyclock/tree/gps
note this project in development and a work-in-progress Pull requests are welcome.
P1 header | UART adapter |
---|---|
P3.1 | RXD |
P3.0 | TXD |
GND | GND |
5V | 5V |
git clone --recursive ...
when you check this repo out, or do git submodule update --init --recursive
in order to fetch stcgal.choose platformio (preferred) or traditional make build
env_default
in platformio.ini
upload_port
as needed in platformio.ini
make clean
make
make flash
override default serial port:
STCGALPORT=/dev/ttyUSB0 make flash
add other options:
STCGALOPTS="-l 9600 -b 9600" make flash
flashing STC15W408AS:
STCGALPROT="stc15" make flash
If you like, you can try pre-compiled binaries here: https://github.com/zerog2k/stc_diyclock/releases
Instead of stcgal, you could alternatively use the official stc-isp tool, e.g stc-isp-15xx-v6.85I.exe, to flash. A windows app, but also works fine for me under mac and linux with wine.
~note due to optimizations that make use of "eeprom" section for holding lookup tables, if you are using 4k flash model mcu AND if using stc-isp tool, you must flash main.hex (as code file) and eeprom.hex (as eeprom file). (Ignore stc-isp warning about exceeding space when loading code file.)~ (not really needed anymore as current build is within 4k code) To generate eeprom.hex, run:
make eeprom
For STC15F204EA, some of the code assumes 11.0592 MHz internal RC system clock (set by stc-isp or stcgal). For example, delay routines might need to be adjusted if this is different. (Most timing has been moved to hardware timers.)
This code is provided as-is, with NO guarantees or liabilities. As the original firmware loaded on an STC MCU cannot be downloaded or backed up, it cannot be restored. If you are not comfortable with experimenting, I suggest obtaining another blank STC MCU and using this to test, so that you can move back to original firmware, if desired.
http://www.stcmcu.com (mostly in Chinese)
stc15f204ea english datasheet: http://www.stcmcu.com/datasheet/stc/stc-ad-pdf/stc15f204ea-series-english.pdf
stc15w408as english datasheet: http://www.stcmicro.com/datasheet/STC15F2K60S2-en2.pdf
sdcc user guide: http://sdcc.sourceforge.net/doc/sdccman.pdf
some examples with NRF24L01+ board: http://jjmz.free.fr/?tag=stc15l204
Maxim DS1302 datasheet: http://datasheets.maximintegrated.com/en/ds/DS1302.pdf
VE3LNY's adaptation of this hardware to AVR (he has some interesting AVR projects there): http://www.qsl.net/v/ve3lny/travel_clock.html
new firmware operation flow diagram
original firmware operation flow state diagram
Kit instructions w/ schematic: scan | PDF