F1C200S >> Assembly

Watchdog


參考資料:
1. pdf
2. lichee
3. mangopi_r
4. allwinner

Work Flow


暫存器


main.s

  .global _start
 
  .equiv GPIO_BASE,  0x01c20800 
  .equiv TIMER_BASE, 0x01c20c00
 
  .equiv PA,        (0x24 * 0)
  .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, =0x1000
  str r1, [r0, #(PA + PORT_CFG0)]
  ldr r1, =0x00
  str r1, [r0, #(PA + 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秒)去重啟系統,不過由於程式是從RAM執行,因此,Reset後,不會有後續動作

完成


返回上一頁