新聞中心

        EEPW首頁 > 手機與無線通信 > 設(shè)計應(yīng)用 > 在MAX-IDE中自動初始化數(shù)據(jù)段

        在MAX-IDE中自動初始化數(shù)據(jù)段

        作者: 時間:2011-04-06 來源:網(wǎng)絡(luò) 收藏

        ;; This is the free-running code, executed on subsequent power-ups, that copies
        ;; values from the flash back into their proper data segment locations.

        move DP[0], #0F000h ; Source: Flash location 7000h
        move BP, #0 ; Dest: Start of RAM
        move Offs, #0
        move LC[0], #100h ; Copy 256 words
        lcall UROM_copyBuffer

        jump main

        ;; This is the first-pass code. A bit of a trick here; because enters
        ;; and exits the loader separately when loading the code and data segment files,
        ;; the application is allowed to execute briefly before the data segment file
        ;; has been loaded. The first four lines under copyFlash ensure that the
        ;; application waits for to load the data segment file before continuing.

        copyToFlash:
        move DP[0], #0h ; Wait for flag variable to be loaded by .
        move Acc, @DP[0] ; Note that this will reset the application; the
        cmp #1234h ; data segment is not loaded while the application
        jump NE, copyToFlash ; is still running.

        move DP[0], #0 ; Start of RAM variable area
        move A[4], #7000h ; Location in flash to write to
        move LC[0], #100h ; Store 256 words in flash 7000h-70FFh

        copyToFlash_loop:
        move DP[0], DP[0] ; Refresh the data pointer to read values correctly,
        ; because calling UROM_flashWrite changes memory
        ; contexts and affects the cached @DP[0] value
        move A[0], A[4] ; Location to write
        move A[1], @DP[0]++ ; Value to write (taken from RAM)
        lcall UROM_flashWrite
        move Acc, A[4]
        add #1
        move A[4], Acc
        djnz LC[0], copyToFlash_loop

        main:
        move PD0, #0FFh ; Set all port 0 pins to output
        move PO0, #000h ; Drive all port 0 pins low (LEDs off)

        move DPC, #1Ch ; Set pointers to word mode
        move DP[0], #varA
        move Acc, @DP[0]
        cmp #1234h ; Verify that the variable is set correctly
        jump NE, fail

        pass:
        move PO0, #55h
        sjump $

        fail:
        sjump $

        segment data

        org 0000h

        varA:
        dw 1234h

        org 00FFh

        varB:
        dw 5678h

        end

        結(jié)論
        MAX-IDE提供的程序段和段工具能夠在存儲器中聲明變量地址,以起始值化這些變量。可以利用應(yīng)用程序在閃存中緩存這些變量,必要時恢復(fù)它們。這種方法允許基于匯編的應(yīng)用程序使用MAX-IDE提供的裝載功能,無論微控制器是否連接JTAG調(diào)試器,都能保持工作。


        上一頁 1 2 3 下一頁

        關(guān)鍵詞: 數(shù)據(jù) 初始 自動 MAX-IDE

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 南溪县| 许昌县| 荣昌县| 万州区| 台湾省| 顺义区| 武穴市| 星子县| 宕昌县| 中卫市| 双辽市| 永州市| 南阳市| 井研县| 绿春县| 新津县| 内江市| 望城县| 长乐市| 壶关县| 蒙城县| 翼城县| 芒康县| 九龙县| 来凤县| 江永县| 墨江| 浦江县| 留坝县| 陈巴尔虎旗| 雷山县| 斗六市| 和平县| 宜兰市| 繁峙县| 望奎县| 五华县| 咸宁市| 两当县| 浪卡子县| 衡水市|