創作內容

1 GP

LAB2:Blinky LED

作者:你媽在旋轉│2024-11-30 00:22:47│巴幣:2│人氣:31
LAB2:Blinky LED

注意使用CALL時,被呼叫的instruction不能存放到0x0FF以後的位置,因為使用call使記憶體位置被存放到program counter時,記憶體位置的第8個bit會被reset為0。

解決方法:設置linker中addional options來指定instructions的起始位置。
把-Wl,-PresetVect=00h這段指令丟到pic-as linker的addional options中。

-Wl,:Options passed to the linker
-P{label} = {addresss} : 指定label中的instructions在記憶體起始存放的位置

NOTE:可以搭配ORG指令使用
PROCESSOR 10F206

; PIC10F206 Configuration Bit Settings
; Assembly source line config statements
; CONFIG

CONFIG  WDTE = OFF            ; Watchdog Timer (WDT disabled)
CONFIG  CP = OFF              ; Code Protect (Code protection off)
CONFIG  MCLRE = OFF           ; Master Clear Enable (GP3/MCLR pin fuction is digital I/O, MCLR internally tied to VDD)

// config statements should precede project file includes.

#include <xc.inc>

PSECT resetVect, class=CODE, delta=2

resetVect:
    PAGESEL main
    goto main

PSECT CODE, delta=2
main:
    movlw 0b00001110
    tris 6
    nop
    movlw 0b11011111
    option
    nop
    movlw 0b11110111
    movwf  0x07
    nop

mainloop:
    nop

blink:
    bsf GP0
    movlw 53
    call delay
    bcf GP0
    movlw 53
    call delay
    goto blink
    nop

delay:
    movwf 0x12
out_out_loop:
    movwf 0x11
outer_loop:
    movwf 0x10
delay_loop:
    decfsz 0x10, 1
    goto delay_loop
    decfsz 0x11, 1
    goto outer_loop
    decfsz 0x12, 1
    goto out_out_loop
    retlw 0
    nop

END resetVect

引用網址:https://home.gamer.com.tw/TrackBack.php?sn=6047864
All rights reserved. 版權所有,保留一切權利

相關創作

留言共 0 篇留言

我要留言提醒:您尚未登入,請先登入再留言

1喜歡★betrayer0125 可決定是否刪除您的留言,請勿發表違反站規文字。

前一篇:LAB1:點亮LED... 後一篇:LAB3:Four-st...

追蹤私訊切換新版閱覽

作品資料夾

russell11大家
我翻譯的〈羅生門〉全文免費公開中! 方格子 https://vocus.cc/article/66a54f4efd89780001e65ee1看更多我要大聲說昨天20:27


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】