微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > GNU ARM汇编--(八)s3c2440的watchdog

GNU ARM汇编--(八)s3c2440的watchdog

时间:11-26 来源:互联网 点击:

  1. e,0@关掉重启信号
  2. .equWTDAT,0x53000004
  3. .equCount_reload,50000@定时器定为2SPCLK=100MPCLK/(Pre_scaler+1)/clock_select=100M/(249+1)/16=25k50000/25k=2s
  4. .equWTCNT,0x53000008
  5. .equCount,50000
  6. .global_start
  7. _start:breset
  8. ldrpc,_undefined_instruction
  9. ldrpc,_software_interrupt
  10. ldrpc,_prefetch_abort
  11. ldrpc,_data_abort
  12. ldrpc,_not_used
  13. @birq
  14. ldrpc,_irq
  15. ldrpc,_fiq
  16. _undefined_instruction:.wordundefined_instruction
  17. _software_interrupt:.wordsoftware_interrupt
  18. _prefetch_abort:.wordprefetch_abort
  19. _data_abort:.worddata_abort
  20. _not_used:.wordnot_used
  21. _irq:.wordirq
  22. _fiq:.wordfiq
  23. .balignl16,0xdeadbeef
  24. reset:
  25. ldrr3,=WTCON
  26. movr4,#0x0
  27. strr4,[r3]@disablewatchdog
  28. ldrr0,=GPBCON
  29. ldrr1,=0x15400
  30. strr1,[r0]
  31. ldrr2,=GPBDAT
  32. ldrr1,=0x160
  33. strr1,[r2]
  34. blclock_setup
  35. bldelay
  36. msrcpsr_c,#0xd2@进入中断模式
  37. ldrsp,=3072@中断模式的栈指针定义
  38. msrcpsr_c,#0xd3@进入系统模式
  39. ldrsp,=4096@设置系统模式的栈指针
  40. @--------------------------------------------
  41. ldrr0,=GPBUP
  42. ldrr1,=0x03f0
  43. strr1,[r0]
  44. ldrr0,=GPFCON
  45. ldrr1,=0x2ea@0x2
  46. strr1,[r0]
  47. ldrr0,=EXTINT0
  48. @ldrr1,=0x8f888@0x0@0x8f888@~(7|(7<4)|(7<8)|(7<16))//低电平触发中断
  49. ldrr1,=0xafaaa@0x0@0x8f888//下降沿触发中断
  50. strr1,[r0]
  51. ldrr0,=EINTPEND
  52. ldrr1,=0xf0@0b10000
  53. strr1,[r0]
  54. ldrr0,=EINTMASK
  55. ldrr1,=0x00@0b00000
  56. strr1,[r0]
  57. ldrr0,=SRCPND
  58. ldrr1,=0x3ff@0x1@0b11111
  59. strr1,[r0]
  60. ldrr0,=SUBSRCPND
  61. ldrr1,=0x1<13
  62. strr1,[r0]
  63. ldrr0,=INTPND
  64. ldrr1,=0x3ff@0x1@0b11111
  65. strr1,[r0]
  66. ldrr0,=INTSUBMSK
  67. ldrr1,=0x0<13
  68. strr1,[r0]
  69. ldrr0,=INTMSK
  70. ldrr1,=0xfffff000@0b00000
  71. strr1,[r0]
  72. MRSr1,cpsr
  73. BICr1,r1,#0x80
  74. MSRcpsr_c,r1
  75. blmain
  76. irq:
  77. sublr,lr,#4
  78. stmfdsp!,{r0-r12,lr}
  79. blirq_isr
  80. ldmfdsp!,{r0-r12,pc}^
  81. irq_isr:
  82. ldrr2,=GPBDAT
  83. ldrr1,=0x0e0
  84. strr1,[r2]
  85. ldrr0,=EINTPEND
  86. ldrr1,=0xf0
  87. strr1,[r0]
  88. ldrr0,=SRCPND
  89. ldrr1,=0x3ff@0b11111
  90. strr1,[r0]
  91. ldrr0,=SUBSRCPND
  92. ldrr1,=0x1<13
  93. strr1,[r0]
  94. ldrr0,=INTPND
  95. ldrr1,=0x3ff@0b11111
  96. strr1,[r0]
  97. movpc,lr
  98. delay:
  99. ldrr3,=0xffffff
  100. delay1:
  101. subr3,r3,#1
  102. cmpr3,#0x0
  103. bnedelay1
  104. movpc,lr
  105. clock_setup:
  106. ldrr0,=LOCKTIME
  107. ldrr1,=0xffffffff
  108. strr1,[r0]
  109. ldrr0,=CLKdivN
  110. ldrr1,=(divN_UPLL<3)|(HdivN<1)|(PdivN<0)
  111. strr1,[r0]
  112. ldrr0,=UPLLCON
  113. ldrr1,=(U_Mdiv<12)|(U_Pdiv<4)|(U_Sdiv<0)@Fin=12MUPLL=48M
  114. strr1,[r0]
  115. nop
  116. nop
  117. nop
  118. nop
  119. nop
  120. nop
  121. nop
  122. ldrr0,=MPLLCON
  123. ldrr1,=(M_Mdiv<12)|(M_Pdiv<4)|(M_Sdiv<0)@Fin=12MFCLK=400M
  124. strr1,[r0]
  125. movpc,lr
  126. main:
  127. ldrr0,=WTDAT
  128. ldrr1,=Count_reload
  129. strr1,[r0]
  130. ldrr0,=WTCNT
  131. ldrr1,=Count
  132. strr1,[r0]
  133. ldrr0,=WTCON
  134. ldrr1,=(Pre_scaler<8)|(wd_timer<5)|(clock_select<3)|(int_gen<2)|(reset_enable)
  135. strr1,[r0]
  136. ledloop:
  137. ldrr1,=0x1c0
  138. strr1,[r2]
  139. bldelay
  140. ldrr1,=0x1a0
  141. strr1,[r2]
  142. bldelay
  143. ldrr1,=0x160
  144. strr1,[r2]
  145. bldelay
  146. ldrr1,=0x0e0
  147. strr1,[r2]
  148. bldelay
  149. bledloop
  150. undefined_instruction:
  151. nop
  152. software_interrupt:
  153. nop
  154. prefetch_abort:
  155. nop
  156. data_abort:
  157. nop
  158. not_used:
  159. nop
  160. fiq:
  161. nop


程序实现的是:一个正常的流水灯,定时器每隔2s触发一次中断,中断处理中点亮第四个LED.

稍微该一下上面的代码:

.equ int_gen, 0 @关中断
.equ reset_enable, 1 @打开重启信号

打开重启信号,则可以看到每隔2s系统就重启一次.

如果在循环中加入:

ldr r0, =WTCNT @喂狗
ldr r1, =Count
str r1, [r0]

那么,这又是一个标准的流水灯了.而且是有watchdog保护的流水灯了.

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top