微處理器 - STMicroelectronics STM8S103 - Assembly - UART



暫存器


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

    .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
loop:
    mov UART1_DR, #0x55
    ldw x, #50000
d0:
    decw x
    jrne d0
    jp loop

完成