NUC972 >> Assembly

Watchdog Timer(WDT)


參考資訊:
1. pdf
2. NUC970_NonOS_BSP
3. NUC972 ARM MPU资料不是足够完善
4. 要通过硬件power on setting打开WDT,否则WDT不可用

WDT_S


解鎖順序:0x59、0x16、0x88


WDTEN、RSTEN不是Read Only


main.s

  .equ GPIOB_DIR,     (0xb8003000 + 0x40)
  .equ GPIOB_DATAOUT, (0xb8003000 + 0x44)
  .equ CLK_PCLKEN0,   (0xb0000200 + 0x18)
  .equ WDT_CTL,       (0xb8001800 + 0x00)
  .equ WDT_ALTCTL,    (0xb8001800 + 0x04)
  .equ SYS_REGWPCTL,  (0xb0000000 + 0x1fc)
  .equ CLK_DIVCTL8,   (0xb0000200 + 0x40)
  
  .text
  .align 2
  .global _start
_start:    b reset
_undef:    b .
_swi:      b .
_pabort:   b .
_dabort:   b .
_reserved: b .
_irq:      b .
_fiq:      b .
  
reset:
  ldr r0, =CLK_PCLKEN0
  ldr r1, [r0]
  orr r1, #((1 << 3 ) | ( 1 << 0))
  str r1, [r0]
  
  ldr r0, =CLK_DIVCTL8
  ldr r1, [r0]
  and r1, #0xffffffcf
  orr r1, #0x00000020
  str r1, [r0]
 
  ldr r0, =SYS_REGWPCTL
  ldr r1, =0x59
  ldr r2, =0x16
  ldr r3, =0x88
  str r1, [r0]
  str r2, [r0]
  str r3, [r0]
 
  ldr r0, =WDT_CTL
  ldr r1, =0x78f
  str r1, [r0]
   
  ldr r0, =GPIOB_DIR
  ldr r1, =(1 << 0)
  str r1, [r0]
loop:
  ldr r0, =GPIOB_DATAOUT
  ldr r1, =(1 << 0)
  str r1, [r0]
  ldr r4, =100000
1:
  nop
  subs r4, r4, #1
  bne 1b
  ldr r0, =GPIOB_DATAOUT
  ldr r1, =~(1 << 0)
  str r1, [r0]
  ldr r4, =100000
1:
  nop
  subs r4, r4, #1
  bne 1b
  b loop
  .end

P.S. 除了詭異的SYS_PWRON,還需要注意PA.3(1 = WDT is ON after power-on)腳位的設定,司徒目前PA.3是懸空,建議接到VCC,正確使用WDT

Watchdog Reset後,SDRAM資料消失,LED不再閃爍


返回上一頁