LPC2103 >> Assembly

WatchDog Timer(WDT)


參考資料:
1. pdf

暫存器




main.s

  .equ IODIR,  0xe0028008
  .equ IOCLR,  0xe002800c
  .equ IOSET,  0xe0028004
  .equ PCON,   0xe01fc0c0
  .equ WDMOD,  0xe0000000
  .equ WDTC,   0xe0000004
  .equ WDFEED, 0xe0000008
 
  .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, =WDTC
  ldr r1, =500000
  str r1, [r0]
  
  ldr r0, =WDMOD
  ldr r1, =0x03
  str r1, [r0]

  ldr r0, =WDFEED
  ldr r1, =0xaa
  ldr r2, =0x55
  str r1, [r0]
  str r2, [r0]

  ldr r0, =IODIR
  ldr r1, =(1 << 22)
  str r1, [r0]
loop: 
  ldr r0, =IOCLR
  ldr r1, =(1 << 22)
  str r1, [r0]
  ldr r4, =10000
1:
  nop
  subs r4, r4, #1
  bne 1b

  ldr r0, =IOSET
  ldr r1, =(1 << 22)
  str r1, [r0]
  ldr r4, =10000
1:
  nop
  subs r4, r4, #1
  bne 1b
  b loop
  .end

觀察LED的變化


返回上一頁