開發板

接腳:
| STC | PL2303 | 
|---|---|
| GND | GND | 
| P3.0 | UART TX | 
| P3.1 | UART RX | 

安裝stcgal
$ cd $ pkg install libtool automake pkg-config root-repo python $ git clone https://github.com/grigorig/stcgal $ cd stcgal $ ./setup.py build $ ./setup.py install
main.c
#include <8051.h>
#include <compiler.h>
SFR(P5, 0xC8);
  
void delay(unsigned long cnt)
{
    while (cnt--);
}
  
void main(void)
{
    while (1) {
        P5 = 0xff;
        delay(1000000);
        P5 = 0x00;
        delay(1000000);
    }
}
編譯
$ sdcc main.c
main.ihx
:03000000020006F5 :03005F0002000399 :0300030002008573 :20006200AC82AD83AEF0FF8C008D018E028F031CBCFF091DBDFF051EBEFF011FE8494A4BC8 :1F00820070E52275C8FF90424075F00FE412006275C80090424075F00FE412006280E44F :06003500E478FFF6D8FD9F :200013007900E94400601B7A009000A5780175A000E493F2A308B8000205A0D9F4DAF275EE :02003300A0FF2C :20003B007800E84400600A790175A000E4F309D8FC7800E84400600C7900900001E4F0A3C3 :04005B00D8FCD9FAFA :0D0006007581071200A1E58260030200036E :0400A1007582002242 :00000001FF
燒錄
$ tsudo stcgal -p /dev/ttyMT0 -P stc15 main.ihx
完成