微處理器 - Microchip PIC12F1822 - Assembly - LED



TRISA(方向設定)、PORTA(I/O資料)


main.s

    list p=12f1822, r=hex
    #include <p12f1822.inc>
    __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF
    __config _CONFIG2, _LVP_OFF

    #define tmp1 0x20
    #define tmp2 0x21

    org 0x0000
    goto start
  
    org 0x0100
start:
    banksel TRISA
    clrf TRISA

loop:
    banksel PORTA
    bcf PORTA, 0
    call delay

    banksel PORTA
    bsf PORTA, 0
    call delay
    goto loop

delay:
    banksel tmp1
    movlw 0x16
    movwf tmp2
    movlw 0xff
    movwf tmp1
    decfsz tmp1, f
    goto $-1
    decfsz tmp2, f
    goto $-3
    return 
    end

編譯

$ gpasm main.s

燒錄(File => Import Hex)
型號選擇:Device Family => Midrange => 1.8V Min

P.S. VDD PICkit3 On記得打勾

完成