微處理器 - Lattice GAL22V10 - Assembly - LED



參考資訊:
https://www.stcmicro.com/datasheet/STC15F204EA-cn.pdf
https://www.stcmicro.com/datasheet/STC15F2K60S2-en.pdf

Register



main.s

    .org 0h
    jmp start
   
    .org 100h
start:
    setb p1.2
    call delay_1s
    clr p1.2
    call delay_1s
    jmp start
  
    ; 1t + ((1t + (4t * 250) + 4t) * 200t) + 4t = 201005t
    ; 11.0592MHz = 0.09042us
    ; 201005t * 0.09042us = 18175us
delay_18ms: 
    mov r7, #200
d0:
    mov r6, #250
d1: 
    djnz r6, d1
    djnz r7, d0
    ret
 
    ; 1t + ((4t + 201005t + 4t) * 55) + 4t = 11055720t
    ; 11055720t * 0.09042us = 999658us ~= 1s
delay_1s: 
    mov r5, #55
d2: 
    call delay_18ms
    djnz r5, d2
    ret
    .end

Makefile

all:
	mcu8051ide --compile main.s

flash:
	timeout 30 stcgal -P stc15 -p /dev/ttyUSB0 -l 9600 -b 9600 -t 11059 main.hex

clean:
	rm -rf main.hex main.adf main.adf~ main.bin main.bin~ main.hex~ main.lst main.lst~

編譯、燒錄

$ make
$ make flash

P.S. 執行make flash後, 再上電STC15即可進入燒錄模式

完成