STM8S103 >> Assembly
Flash
參考資訊:
1. eeprom-readwrite
暫存器
Flash
main.s
.equ PD_ODR, 0x500f .equ PD_IDR, 0x5010 .equ PD_DDR, 0x5011 .equ PD_CR1, 0x5012 .equ PD_CR2, 0x5013 .equ UART1_DR, 0x5231 .equ UART1_BRR1, 0x5232 .equ UART1_BRR2, 0x5233 .equ UART1_CR2, 0x5235 .equ FLASH_IAPSR, 0x505f .equ FLASH_PUKR, 0x5062 .area data .area sseg .area home int main .area cseg main: mov PD_DDR, #0x20 mov PD_CR1, #0x20 mov PD_CR2, #0x20 ; 9600bps mov UART1_BRR2, #0x00 mov UART1_BRR1, #0x0d mov UART1_CR2, #0x08 mov FLASH_PUKR, #0x56 mov FLASH_PUKR, #0xae ; flash write ld a, #0x55 ld 0x9000, a loop: ; flash read ld a, 0x9000 ld UART1_DR, a ldw x, #30000 d0: decw x jrne d0 jp loop
編譯、燒錄
$ sdasstm8 -o main.s $ sdldstm8 -ni -b home=0x8000 -b cseg=0x8080 -b data=0x0001 -b sseg=0xffff main.rel $ sudo stm8flash -c stlinkv2 -p stm8s103f3 -u $ sudo stm8flash -c stlinkv2 -p stm8s103f3 -s flash -w main.ihx
完成