<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 模擬技術(shù) > 設計應用 > 在MAXQ8913微控制器中從RAM執行應用程序

在MAXQ8913微控制器中從RAM執行應用程序

作者: 時(shí)間:2010-01-13 來(lái)源:網(wǎng)絡(luò ) 收藏

數據傳遞操作
如上所述,在中執行代碼時(shí),有兩個(gè)與內存映射相關(guān)的事項發(fā)生了變化。第一,程序閃存現在被映射至數據內存。這意味著(zhù)我們可通過(guò)任意數據指針直接從程序閃存讀取數據,如下所示。

本文引用地址:http://dyxdggzs.com/article/188391.htm

;; Read the banner string from flash and output it over the serial port. Since
;; we are running from , we can read from the flash directly without having
;; to use the Utility ROM data transfer functions (moveDP0inc, etc...).

move SC.4, #0
move DPC, #0 ; Set pointers to byte mode.
move DP[0], #(stringData * 2) ; Point to byte address of string data.

stringLoop:
move Acc, @DP[0]++
sjump Z, stringEnd
lcall #TxChar
sjump stringLoop
stringEnd:
move DPC, #1Ch ; Set pointers to word mode.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This portion of the code (addresses 200h and higher) will remain in flash.

org 0200h

stringData:
db 0Dh, 0Ah, Executing code from ...., 00h

請注意,如圖1所示,SC.4 (CDA0)位影響將哪一半程序閃存(上半頁(yè)或下半頁(yè))以字節模式映射至數據內存。當使用字模式指針時(shí),整個(gè)程序閃存被一次性映射至數據內存。

第二,現在雖然閃存在數據空間可存取,但SRAM不可直接存取。這意味著(zhù)不能對SRAM的存儲單元進(jìn)行讀或寫(xiě)操作,應用程序必須采取迂回的方法。從SRAM存儲單元讀取數據可按照在閃存中運行的代碼從閃存存儲單元讀取數據相同的方式實(shí)現―利用應用ROM數據傳遞函數(moveDP0inc等)。然而,由于在應用ROM中沒(méi)有類(lèi)似的函數可實(shí)現直接寫(xiě)操作,所以應用程序必須提供一個(gè)小函數駐留在閃存中,該函數可被RAM中駐留的代碼直接調用來(lái)執行寫(xiě)操作。

以下的代碼演示用來(lái)讀和寫(xiě)RAM變量varA的方法,其初始值隨其它部分的應用程序被從閃存復制到RAM,地址范圍為0000h-01FFh。

scall printVar
scall incrVar
scall printVar
scall incrVar
scall printVar
scall incrVar

move Acc, #0Dh
lcall #TxChar
move Acc, #0Ah
lcall #TxChar

sjump $


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Variables stored in RAM (program) space. They can be read using the
;; Utility ROM data transfer functions (such as UROM_moveDP0) and written
;; using the writeDP0 function which remains in flash.
;;

varA:
dw 'A'


;================================================================
;=
;= printVar
;=
;= Reads the varA RAM variable value and sends it over the serial port.
;=

printVar:
move DPC, #1Ch ; Word mode
move DP[0], #varA ; Variable's location in UROM data space
lcall UROM_moveDP0 ; Moves variable value into GR.
move Acc, GR
lcall #TxChar
ret


;==============================================================
;=
;= incrVar
;=
;= Reads the varA RAM variable value, adds 1 to it, and stores it back in RAM.
;=

incrVar:
move DPC, #1Ch ; Word mode
move DP[0], #varA ; Variable's location in UROM data space
lcall UROM_moveDP0 ; Moves variable value into GR.

move Acc, GR
add #1
move GR, Acc
lcall writeDP0

ret

;==================================================================
;=
;= TxChar
;=
;= Outputs a character to the serial port.
;=
;= Inputs : Acc.L - Character to send.
;=

org 01F0h
move SBUF, Acc ; Send character.
TxChar_Loop:
move C, SCON.1 ; Check transmit flag.
sjump NC, TxChar_Loop ; Stall until last transmit has completed.
move SCON.1, #0 ; Clear the transmit flag.
ret


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This portion of the code (addresses 200h and higher) will remain in flash.

org 0200h

stringData:
db 0Dh, 0Ah, Executing code from RAM...., 00h


;===============================================================
;=
;= WriteRAM
;=
;= This is a routine that can be called by code running in the RAM to load
;= a new value into a byte or word location in the RAM.
;=
;= Inputs : DP[0] - Location to write (absolute starting at 0000h) in RAM.
;= GR - Value to write to the RAM location.
;=
;= Notes : DP[0] must be configured to operate in word or byte mode as
;= desired before calling this function. Following a call to this
;= function, DP[0] must be refreshed before it is used to read data.
;=

writeDP0:
move @DP[0], GR
ret

在執行時(shí),示例代碼通過(guò)串口輸出以下的文字(圖2)。

圖2. 示例代碼通過(guò)串口的輸出文字


圖2. 示例代碼通過(guò)串口的輸出文字

結論
利用及其它采用的Harvard內存映射架構,可以將不同的物理內存段(例如數據SRAM)映射為程序或數據內存空間。在數據SRAM中執行部分應用程序為性能提升和降低功耗提供了潛力。不過(guò)該過(guò)程也增加了應用程序的復雜性。


上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: MAXQ 8913 RAM 微控制器

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>