微處理器 - Allwinner F1C100S (荔枝派Nano) - Assembly - Watchdog



參考資料:
http://nano.lichee.pro/
https://mangopi.org/mangopi_r

Work Flow


暫存器


main.s

    .global _start

    .equiv GPIO_BASE,  0x01c20800 
    .equiv TIMER_BASE, 0x01c20c00

    .equiv PE,        (0x24 * 4)
    .equiv PORT_CFG0, 0x00
    .equiv PORT_DATA, 0x10

    .equiv WDOG_IRQ_EN_REG,  0xa0
    .equiv WDOG_IRQ_STA_REG, 0xa4
    .equiv WDOG_CTRL_REG,    0xb0
    .equiv WDOG_CFG_REG,     0xb4
    .equiv WDOG_MODE_REG,    0xb8

    .arm
    .text
_start:
    .long 0xea000016
    .byte 'e', 'G', 'O', 'N', '.', 'B', 'T', '0'
    .long 0, __spl_size
    .byte 'S', 'P', 'L', 2
    .long 0, 0
    .long 0, 0, 0, 0, 0, 0, 0, 0
    .long 0, 0, 0, 0, 0, 0, 0, 0
     
_vector:
    b reset
    b .
    b .
    b .
    b .
    b .
    b .
    b .
     
reset:
    ldr r0, =GPIO_BASE
    ldr r1, =0x00010000
    str r1, [r0, #(PE + PORT_CFG0)]
    ldr r1, =0x00
    str r1, [r0, #(PE + PORT_DATA)]

    ldr r0, =TIMER_BASE
    ldr r1, =(0xa57 << 1) | 1
    str r1, [r0, #WDOG_CTRL_REG]
    ldr r1, =1
    str r1, [r0, #WDOG_CFG_REG]
    ldr r1, =(1 << 4) | 1
    str r1, [r0, #WDOG_MODE_REG]
0:
    nop
    b 0b
    .end

P.S. 點亮LED後,等待Watchdog(1秒)去重啟系統,達到閃爍LED的效果

完成