ARM notes: (Based On TQ2440)--- 菜菜鸟裸奔年代(1) MDK下点亮LED
对汇编有点了解后开始点灯,应该在用中学才是最快的.不管如何首先想办法点灯.============================================================================================================================================
用Jlink,用 MDK 4 . 其中某个配置页面如下:
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_590748OOP2HE.jpg
配置Jlink (原文件名:Note2-1.jpg)
============================================================================================================================================
配置完成后开始我们的程序编写. 程序如何编写暂时还不会, 上网下载了一份 , 看了看, 关键是启动代码(汇编代码). 但是想想:
如果我自己写的话,就是需要关闭看门狗, 然后让PC指向main函数.
稍微看了下keil自带的启动代码, 但是有部分我不明白,我将认为没有用的一部分delete了, 这样做是想让代码看起来稍微简洁点.
下面是工程文件.
MDK Project ourdev_590856KBWMT2.zip(文件大小:48K) (原文件名:Note2_Led.zip)
=======================================================================
; 看看启动代码:
Mode_USR EQU 0x10
Mode_FIQ EQU 0x11
Mode_IRQ EQU 0x12
Mode_SVC EQU 0x13
Mode_ABT EQU 0x17
Mode_UND EQU 0x1B
Mode_SYS EQU 0x1F
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
;----------------------- Stack and Heap Definitions ----------------------------
UND_Stack_SizeEQU 0x00000000
SVC_Stack_SizeEQU 0x00000008
ABT_Stack_SizeEQU 0x00000000
FIQ_Stack_SizeEQU 0x00000000
IRQ_Stack_SizeEQU 0x00000080
USR_Stack_SizeEQU 0x00000400
ISR_Stack_SizeEQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
FIQ_Stack_Size + IRQ_Stack_Size)
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE USR_Stack_Size
__initial_sp SPACE ISR_Stack_Size
Stack_Top EQU Stack_Mem + ISR_Stack_Size
Heap_Size EQU 0x00000000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
;__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
;----------------------- Memory Definitions ------------------------------------
; Internal Memory Base Addresses
IRAM_BASE EQU 0x40000000
;----------------------- Watchdog Timer Definitions ----------------------------
WT_BASE EQU 0x53000000 ; Watchdog Timer Base Address
WTCON_OFS EQU 0x00 ; Watchdog Timer Control Register Offset
WTDAT_OFS EQU 0x04 ; Watchdog Timer Data Register Offset
WTCNT_OFS EQU 0x08 ; Watchdog Timer Count Register Offset
WT_SETUP EQU 1
WTCON_Val EQU 0x00000000
WTDAT_Val EQU 0x00008000
;----------------------- I/O Port Definitions ----------------------------------
;----------------------- CODE --------------------------------------------------
PRESERVE8
; Area Definition and Entry Point
;Startup Code must be linked first at Address at which it expects to run.
AREA RESET, CODE, READONLY
ARM
IF :LNOT::DEF:__EVAL
IMPORT||Image$$ER_ROM1$$RO$$Length||
IMPORT||Image$$RW_RAM1$$RW$$Length||
ENDIF
; Exception Vectors
;Mapped to Address 0.
;Absolute addressing mode must be used.
;Dummy Handlers are implemented as infinite loops which can be modified.
;RESET
Vectors LDR PC, Reset_Addr
LDR PC, Undef_Addr
LDR PC, SWI_Addr
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
IF :DEF:__EVAL
DCD 0x4000
ELSE
DCD ||Image$$ER_ROM1$$RO$$Length||+\
||Image$$RW_RAM1$$RW$$Length||
ENDIF
LDR PC, IRQ_Addr
LDR PC, FIQ_Addr
IF :DEF:__RTX
IMPORTSWI_Handler
IMPORTIRQ_Handler_RTX
ENDIF
Reset_Addr DCD Reset_Handler
Undef_Addr DCD Undef_Handler
SWI_Addr DCD SWI_Handler
PAbt_Addr DCD PAbt_Handler
DAbt_Addr DCD DAbt_Handler
DCD 0 ; Reserved Address
IF :DEF:__RTX
IRQ_Addr DCD IRQ_Handler_RTX
ELSE
IRQ_Addr DCD IRQ_Handler
ENDIF
FIQ_Addr DCD FIQ_Handler
Undef_Handler B Undef_Handler
IF :DEF:__RTX
ELSE
SWI_Handler B SWI_Handler
ENDIF
PAbt_Handler B PAbt_Handler
DAbt_Handler B DAbt_Handler
IRQ_Handler PROC
EXPORTIRQ_Handler
B .
ENDP
FIQ_Handler B FIQ_Handler
; Reset Handler
EXPORTReset_Handler
Reset_Handler
; Watchdog Setup ---------------------------------------------------------------
IF WT_SETUP != 0
LDR R0, =WT_BASE
LDR R1, =WTCON_Val
LDR R2, =WTDAT_Val
STR R2,
STR R2,
STR R1,
ENDIF
; Clock Setup ------------------------------------------------------------------
; Memory Controller Setup ------------------------------------------------------
; I/O Pins Setup ---------------------------------------------------------------
; Copy Exception Vectors to Internal RAM ---------------------------------------
; Enter the C code -------------------------------------------------------------
IMPORTmain
LDR R0, =main
BX R0
IF :DEF:__MICROLIB
EXPORT__heap_base
EXPORT__heap_limit
ELSE
; User Initial Stack & Heap
AREA |.text|, CODE, READONLY
IMPORT__use_two_region_memory
EXPORT__user_initial_stackheap
__user_initial_stackheap
LDR R0, =Heap_Mem
LDR R1, =(Stack_Mem + USR_Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ENDIF
END
;==============================================================================
=======================================================================================================================
=======================================================================================================================
上面的代码中.有许多东西是我不想要的,于是继续将除了设置看门狗和跳转到main这两个功能的代码外全部删除:
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_590858L9I2SV.jpg
只有设置Watchdog和跳转到main的StartCode (原文件名:startCode.jpg)
这样看起来够简洁了,而且这些刚好也是我能看懂的
下面是工程:
点击此处下载 ourdev_590860ZOXDCA.zip(文件大小:50K) (原文件名:Note2_Led简单startcode.zip)
=======================================================================================================================
=======================================================================================================================
下面的是c文件的:
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_590863MJMVPW.jpg
(原文件名:maincode.jpg)
这个看起来和以前玩过的C51 AVR 以及XS128似乎没有什么太大的不同.
以后写代码就准备在这里一点点的添加了. mark mark Mark MARK LZ有没有QQ一起学习,讨论,我也刚学
QQ:57706999 楼主好强啊,我最近也刚开始玩STM32 哈哈我也是TQ2440不过是7寸屏的一起学习啦 mark mark mark 好贴 一起学习 刚入手 我配置了,还是下载不进去
页:
[1]