PIC16F877 Sayı 5
Yazı dizimizde bu ay, PIC kullanan ve PIC kullanmak isteyen okurlarımız için değişik program seçenekleri sunarak olabilecek alternatiflerden bahsediyor yazarımız.
Evet değerli okurlarımız, yazı dizimizin bu bölümünde geçen ay değindiğimiz ve bir çok okurdan aldığım e-mail� ler doğrultusunda ilgi topladığını gördüğüm bir konudan Parsic� den bahsedeceğim. Parsic, program yazmaktan hoşlanmayanlar ya da projeyi bir an önce tamamlamak isteyenler veya son yıllarda alışageldiğimiz ve hemen her programlama dilinin başına gelen �Visual� ifadesine alışanlar, sıcak bakanlar ve bu şekilde tasarımdan hoşlananlar için geliştirilmiş bir program. Program çalıştırıldığında seçilecek bileşenleri tanımlayan çeşitli toolbarlar� ı içeren hazır yapısıyla kullanıcının hemen tüm ihtiyaçlarını karşılayacak tasarım bileşenlerini sunmakta. Program aşağıdaki pencerenin kliklenmesinin ardından ekrana geldiğinde; Grid� lerden oluşan zeminiyle kolayca tasarım yapılabilecek Visual Basic� in editörüne benzer bir editor ekrana gelmektedir.
Program çalıştırıldığında ekranda PIC programı yapılırken ihtiyaç duyulabilecek hemen tüm bileşenleri içeren toolbarlar görüntülenir. Bu toolbarlar kullanılarak zamanlayıcı, analog / dijital veri girişi vb. aşağıda örnek programda göründüğü gibi doğrudan araç çubukları kullanılarak hazırlanan program, görsel olarak hazırlanıp, nesneler üzerinde değer belirlenmesi ve bağlantısı yapıldığında arka planda da program tarafından PIC Kaynak kodu yazılmaktadır.
Büyük görmek için resme Tıklayın!
Bu kodu görebilmek için Window menüsünden source seçilerek aşağıdaki gibi açılan ek pencereden PIC kaynak kodları görüntülenir. �Project file:� projeye ait kaynak kodunun kaydedileceği sürücü, klasör ve ismi de verilmektedir. Kaynak kodunu kaydederken sürücü, klasör ve kaynak kodu ismi verebilmek için File menüsünden Save Source As … seçeneğine girilerek belirlenir.
Büyük görmek için resme Tıklayın!
; Source created with Parsic Version 3.x
; at : 01.03.2001 11:47:23
; Project File : C:PROGRA~1MPLABPARSICEXAMPLELCD.PIC
; Project Version : 1.0.23
; Created : 13.04.2000 00:05:00
; Last change : 09.04.2001 10:10:00
PROCESSOR 16F877
INCLUDE P16F877.INC
RADIX DEC
__IDLOCS H'0100'
__CONFIG _CP_OFF & _PWRTE_ON & _WDT_OFF & _BODEN_ON & _XT_OSC & _LVP_OFF & _CPD_OFF & _DEBUG_OFF
; Diverses
ZERO EQU Z ; ZERO-Flag
CARRY EQU C ; CARRY-Flag
; Variable
LT1_FD = 32 ; located in Bank 0
ADC0 = 33 ; located in Bank 0
ADC0_HI = 34 ; located in Bank 0
LT2_FD = 35 ; located in Bank 0
LT3_FD = 36 ; located in Bank 0
LT4_FD = 37 ; located in Bank 0
LT5_FD = 38 ; located in Bank 0
LT6_FD = 39 ; located in Bank 0
LT7_FD = 40 ; located in Bank 0
TR1 = 41 ; located in Bank 0
TR1_HI = 42 ; located in Bank 0
S0 = 43 ; located in Bank 0
RAM = 44 ; located in Bank 0
SYS_TMP1 = 115 ; located in Bank 0, 1, 2, 3
SYS_TMP2 = 116 ; located in Bank 0, 1, 2, 3
SYS_TMP3 = 117 ; located in Bank 0, 1, 2, 3
SYS_TMP4 = 118 ; located in Bank 0, 1, 2, 3
SYS_TMP5 = 119 ; located in Bank 0, 1, 2, 3
SYS_TMP6 = 120 ; located in Bank 0, 1, 2, 3
SYS_TMP9 = 121 ; located in Bank 0, 1, 2, 3
SYS_TMP10 = 122 ; located in Bank 0, 1, 2, 3
SYS_WSAV = 123 ; located in Bank 0, 1, 2, 3
SYS_SSAV = 124 ; located in Bank 0, 1, 2, 3
SYS_PSAV = 125 ; located in Bank 0, 1, 2, 3
ERRORLEVEL -302 ; disable warning (Bankswitching)
ERRORLEVEL -306 ; disable warning (Pageswitching)
;****************************************
;Programmanfang
;****************************************
ORG 0
NOP
MOVLW HIGH SYS_INIT ; set page
MOVWF PCLATH
GOTO SYS_INIT
;****************************************
;Interrupt-Adress
;****************************************
MOVWF SYS_WSAV ; save register
SWAPF STATUS,W
CLRF STATUS ; bank 0
MOVWF SYS_SSAV
MOVFW PCLATH
MOVWF SYS_PSAV
CLRF PCLATH
BCF INTCON,T0IF ; Interrupt quitieren
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
INCFSZ TR1,F
GOTO SYS_INT_LABEL_0
INCF TR1_HI,F
SYS_INT_LABEL_0
EXITINT
MOVFW SYS_PSAV
MOVWF PCLATH
SWAPF SYS_SSAV,W ; Register zurück
MOVWF STATUS
SWAPF SYS_WSAV,F
SWAPF SYS_WSAV,W
RETFIE ; RETurn From Interrupt and Enable GIE
;****************************************
; Subroutines
;****************************************
;***************************************************
; Read -> AN0
;***************************************************
READ_AN0
MOVLW B'100'
BSF STATUS,RP0 ; Bank 1
BCF STATUS,RP1 ; Bank 1
MOVWF ADCON1
BSF TRISA,0
BSF ADCON1,ADFM ; Right-Justified
MOVLW B'11000001' ; CH0
BCF STATUS,RP0 ; Bank 0
MOVWF ADCON0
MOVLW 5
MOVWF SYS_TMP1
SYS_ADC_LABEL_0
DECFSZ SYS_TMP1,F
GOTO SYS_ADC_LABEL_0
BSF ADCON0,GO ; Start convert
SYS_ADC_LABEL_1
BTFSC ADCON0,GO ; ready ?
GOTO SYS_ADC_LABEL_1 ; no
BSF STATUS,RP0 ; Bank 1
MOVFW ADRESL
BCF STATUS,RP0 ; Bank 0
MOVWF ADC0
MOVFW ADRESH
MOVWF ADC0_HI
MOVLW 6
BSF STATUS,RP0 ; Bank 1
MOVWF ADCON1
MOVLW B'11111111'
MOVWF TRISA
RETURN
;***************************************************
; Subroutines for LB1
;***************************************************
LCD_LB1_INIT
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF PORTC,4 ; ir-register
LCD_LB1_L1
CALL LCD_LB1_OUT4
DECFSZ SYS_TMP1,F
GOTO LCD_LB1_L1
MOVFW PORTC
ANDLW H'F0'
IORLW B'0011' ; Function Set
MOVWF PORTC
BSF PORTC,5 ; write
BCF PORTC,5
BSF SYS_TMP1,5 ; wait
LCD_LB1_L2
CALL LCD_LB1_OUT4
DECFSZ SYS_TMP1,F
GOTO LCD_LB1_L2
BSF PORTC,5 ; write
BCF PORTC,5
CALL LCD_LB1_OUT4
BSF PORTC,5 ; write
BCF PORTC,5
CALL LCD_LB1_OUT4
BCF PORTC,0 ; 4-Bit Interface
BSF PORTC,5 ; write
BCF PORTC,5
CALL LCD_LB1_OUT4
MOVLW B'00101000' ; Function Set 4-Bit,2-Lines
CALL LCD_LB1_OUT
MOVLW B'00001100' ; Display on, Cursor off, Blink off
CALL LCD_LB1_OUT
MOVLW B'00000110' ; Entrymode set
CALL LCD_LB1_OUT
LCD_LB1_CLR
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF PORTC,4 ; i
r-register
MOVLW B'00000001' ; Display clear
CALL LCD_LB1_OUT
BSF SYS_TMP1,5 ; wait
LCD_LB1_L3
CALL LCD_LB1_OUT4
DECFSZ SYS_TMP1,F
GOTO LCD_LB1_L3
GOTO LCD_LB1_OUT4
;***************************************************
LCD_LB1_GOTOXY
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF PORTC,4 ; ir-register
MOVLW H'40'
BTFSC SYS_TMP2,0 ; Ypos
ADDWF SYS_TMP1,F
MOVLW H'14'
BTFSC SYS_TMP2,1 ; Ypos
ADDWF SYS_TMP1,F
BSF SYS_TMP1,7 ; select dd-ram
GOTO LCD_LB1_OUT1
;***************************************************
LCD_LB1_WRITESTR
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BSF PORTC,4 ; dd-ram
LCD_LB1_WRITESTR1
CALL LCD_LB1_CHAROUT
BSF INTCON,GIE
ANDLW H'FF' ; last is zero
BTFSC STATUS,ZERO
RETURN
MOVWF SYS_TMP1
MOVLW HIGH LCD_LB1_OUT1 ; set page
MOVWF PCLATH
CALL LCD_LB1_OUT1
INCFSZ SYS_TMP4,F ; next char
GOTO LCD_LB1_WRITESTR1
INCF SYS_TMP5,F ; next page
GOTO LCD_LB1_WRITESTR1
LCD_LB1_CHAROUT
BCF INTCON,GIE
MOVFW SYS_TMP5
MOVWF PCLATH
MOVFW SYS_TMP4
MOVWF PCL
;***************************************************
LCD_LB1_DEZO10000
MOVLW LOW 10000
MOVWF SYS_TMP1
MOVLW HIGH 10000
MOVWF SYS_TMP2
CALL LCD_LB1_CONVERTDEZ
MOVF SYS_TMP9,F
BTFSS STATUS,ZERO
GOTO LCD_LB1_DEZO1000
CALL LCD_LB1_CHECKNULL
LCD_LB1_DEZO1000
MOVLW LOW 1000
MOVWF SYS_TMP1
MOVLW HIGH 1000
MOVWF SYS_TMP2
CALL LCD_LB1_CONVERTDEZ
MOVF SYS_TMP9,F
BTFSS STATUS,ZERO
GOTO LCD_LB1_DEZO100
CALL LCD_LB1_CHECKNULL
LCD_LB1_DEZO100
MOVLW LOW 100
MOVWF SYS_TMP1
CLRF SYS_TMP2
CALL LCD_LB1_CONVERTDEZ
MOVF SYS_TMP9,F
BTFSS STATUS,ZERO
GOTO LCD_LB1_DEZO10
CALL LCD_LB1_CHECKNULL
LCD_LB1_DEZO10
MOVLW LOW 10
MOVWF SYS_TMP1
CLRF SYS_TMP2
CALL LCD_LB1_CONVERTDEZ
MOVF SYS_TMP9,F
BTFSS STATUS,ZERO
GOTO LCD_LB1_DEZO1
CALL LCD_LB1_CHECKNULL
LCD_LB1_DEZO1
MOVLW 48
ADDWF SYS_TMP4,W
GOTO LCD_LB1_WRITECHAR
;***************************************************
LCD_LB1_CONVERTDEZ
MOVF SYS_TMP9,F
BTFSS STATUS,ZERO
DECF SYS_TMP9,F
CLRF SYS_TMP6
LCD_LB1_CONVERTDEZ2
INCF SYS_TMP6,F
MOVFW SYS_TMP1
SUBWF SYS_TMP4,F
MOVFW SYS_TMP2
BTFSS STATUS,CARRY
INCFSZ SYS_TMP2,W
SUBWF SYS_TMP5,F
BTFSC STATUS,CARRY
GOTO LCD_LB1_CONVERTDEZ2
MOVFW SYS_TMP2
ADDWF SYS_TMP5,F
MOVFW SYS_TMP1
ADDWF SYS_TMP4,F
BTFSC STATUS,CARRY
INCF SYS_TMP5,F
DECF SYS_TMP6,W
BTFSS STATUS,ZERO
BSF SYS_TMP10,0
RETURN
;***************************************************
LCD_LB1_CONVERTHEX
ANDLW 15
MOVWF SYS_TMP1
MOVLW 48
ADDWF SYS_TMP1,F
MOVLW 58
SUBWF SYS_TMP1,W
BTFSS STATUS,CARRY
GOTO $+3
MOVLW 7
ADDWF SYS_TMP1,F
MOVFW SYS_TMP1
;***************************************************
LCD_LB1_WRITECHAR
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BSF PORTC,4 ; dd-ram
;***************************************************
LCD_LB1_OUT
MOVWF SYS_TMP1 ; store
LCD_LB1_OUT1
CLRF SYS_TMP3 ; LCDWriteStr (first nibble)
LCD_LB1_OUT2
SWAPF SYS_TMP1,W ;high nibble
LCD_LB1_OUT3
ANDLW H'0F' ; mask
MOVWF SYS_TMP2 ; store
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
MOVFW PORTC ; load port
ANDLW H'F0' ; mask
IORWF SYS_TMP2,W ; add cmd
MOVWF PORTC ; out
BSF PORTC,5 ; E high
BCF PORTC,5 ; E low
BTFSC SYS_TMP3,3 ; ready ?
GOTO LCD_LB1_OUT4 ; yes
BSF SYS_TMP3,3 ; second nibble
MOVFW SYS_TMP1
GOTO LCD_LB1_OUT3 ; next nibble
LCD_LB1_OUT4
LCD_LB1_OUTV
DECFSZ SYS_TMP3,F
GOTO LCD_LB1_OUTV
RETURN
;***************************************************
LCD_LB1_CHECKNULL
BTFSS STATUS,ZERO
DECF SYS_TMP9,F
MOVWF SYS_TMP1
BTFSS STATUS,ZERO
BSF SYS_TMP10,0
MOVLW 48
BTFSC SYS_TMP10,0
ADDWF SYS_TMP1,f
MOVLW 32
BTFSS SYS_TMP10,0
ADDWF SYS_TMP1,F
MOVFW SYS_TMP1
GOTO LCD_LB1_WRITECHAR
; 00EA
;****************************************
;Initialisierung
;****************************************
SYS_INIT
MOVLW B'00100000'
MOVWF INTCON
; Ausgangs-Pegel setzen, bevor die Richtung gesetzt wird
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
MOVLW B'00000000'
MOVWF PORTA
MOVLW B'00000000'
MOVWF PORTB
MOVLW B'00000000'
MOVWF PORTC
MOVLW B'00000000'
MOVWF PORTD
MOVLW B'00000000'
MOVWF PORTE
MOVLW 15
BSF STATUS,RP0 ; Bank 1
MOVWF OPTION_REG
MOVLW 6 ; all Digital
MOVWF ADCON1
; Richtung setzen
MOVLW B'11111111'
MOVWF TRISA
MOVLW B'11111111'
MOVWF TRISB
MOVLW B'11000000'
MOVWF TRISC
MOVLW B'11111111'
MOVWF TRISD
MOVLW B'00000111'
MOVWF TRISE
; init vars
; Clear RAM
BCF STATUS,IRP
MOVLW 32
MOVWF FSR
CR1
CLRF INDF
INCF FSR,F
MOVLW H'70'
SUBWF FSR,W
BTFSC STATUS,ZERO
INCF FSR,F
BTFSS FSR,7
GOTO CR1
BSF FSR,5
CR2
CLRF INDF
INCF FSR,F
MOVLW H'F0'
SUBWF FSR,W
BTFSS STATUS,ZERO
GOTO CR2
BSF STATUS,IRP
MOVLW 16
MOVWF FSR
CR3
CLRF INDF
INCF FSR,F
MOVLW H'70'
SUBWF FSR,W
BTFSS STATUS,ZERO
GOTO CR3
MOVLW 144
MOVWF FSR
CR4
CLRF INDF
INCF FSR,F
MOVLW H'EB'
SUBWF FSR,W
BTFSS STATUS,ZERO
GOTO CR4
;***************************************************
; Init LCD -> LB1
;***************************************************
CALL LCD_LB1_INIT
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
CLRF TMR0
BCF INTCON,T0IF
BSF INTCON,GIE ; Interrupt freigeben
;**********************************
;******* Haupt-Programm ***********
;**********************************
MAIN
CALL READ_AN0
;***************************************************
; LCD -> LT1
;***************************************************
; test of positiv edge
BCF STATUS,RP0 ; Bank 0
BTFSC LT1_FD,0
GOTO LABEL_LT1_SETFD
BTFSS S0,2
GOTO LABEL_LT1_SETFD
MOVLW 0
MOVWF SYS_TMP1
MOVLW 1
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
MOVLW LOW TAB_LT1
MOVWF SYS_TMP4
MOVLW HIGH TAB
_LT1
MOVWF SYS_TMP5
MOVLW HIGH LCD_LB1_WRITESTR ; set page
MOVWF PCLATH
CALL LCD_LB1_WRITESTR
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT1_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,2
GOTO LABEL_LT1_SETFD2
BSF LT1_FD,0
GOTO LABEL_LT1_END
LABEL_LT1_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT1_FD,0
LABEL_LT1_END
;***************************************************
; LCD -> LT2
;***************************************************
; test of positiv edge
BTFSC LT2_FD,0
GOTO LABEL_LT2_SETFD
BTFSS S0,2
GOTO LABEL_LT2_SETFD
MOVLW 0
MOVWF SYS_TMP1
MOVLW 2
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
MOVLW LOW TAB_LT2
MOVWF SYS_TMP4
MOVLW HIGH TAB_LT2
MOVWF SYS_TMP5
MOVLW HIGH LCD_LB1_WRITESTR ; set page
MOVWF PCLATH
CALL LCD_LB1_WRITESTR
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT2_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,2
GOTO LABEL_LT2_SETFD2
BSF LT2_FD,0
GOTO LABEL_LT2_END
LABEL_LT2_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT2_FD,0
LABEL_LT2_END
;***************************************************
; LCD -> LT3
;***************************************************
; test of positiv edge
BTFSC LT3_FD,0
GOTO LABEL_LT3_SETFD
BTFSS S0,2
GOTO LABEL_LT3_SETFD
MOVLW 0
MOVWF SYS_TMP1
MOVLW 3
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
MOVLW LOW TAB_LT3
MOVWF SYS_TMP4
MOVLW HIGH TAB_LT3
MOVWF SYS_TMP5
MOVLW HIGH LCD_LB1_WRITESTR ; set page
MOVWF PCLATH
CALL LCD_LB1_WRITESTR
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT3_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,2
GOTO LABEL_LT3_SETFD2
BSF LT3_FD,0
GOTO LABEL_LT3_END
LABEL_LT3_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT3_FD,0
LABEL_LT3_END
;***************************************************
; LCD -> LT4
;***************************************************
; test of positiv edge
BTFSC LT4_FD,0
GOTO LABEL_LT4_SETFD
BTFSS S0,2
GOTO LABEL_LT4_SETFD
MOVLW 6
MOVWF SYS_TMP1
MOVLW 0
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
MOVLW LOW TAB_LT4
MOVWF SYS_TMP4
MOVLW HIGH TAB_LT4
MOVWF SYS_TMP5
MOVLW HIGH LCD_LB1_WRITESTR ; set page
MOVWF PCLATH
CALL LCD_LB1_WRITESTR
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT4_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,2
GOTO LABEL_LT4_SETFD2
BSF LT4_FD,0
GOTO LABEL_LT4_END
LABEL_LT4_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT4_FD,0
LABEL_LT4_END
;***************************************************
; LCD -> LT5
;***************************************************
; test of positiv edge
BTFSC LT5_FD,0
GOTO LABEL_LT5_SETFD
BTFSS S0,0
GOTO LABEL_LT5_SETFD
MOVLW 4
MOVWF SYS_TMP1
MOVLW 1
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
MOVFW ADC0
MOVWF SYS_TMP4
MOVFW ADC0_HI
MOVWF SYS_TMP5
MOVLW 6
MOVWF SYS_TMP6
LABEL_LT5_FIXED
BCF STATUS,CARRY
RLF SYS_TMP4,F
RLF SYS_TMP5,F
DECFSZ SYS_TMP6,F
GOTO LABEL_LT5_FIXED
MOVLW 10
MOVWF SYS_TMP6
LCD_LT5_BIN1
MOVLW HIGH LCD_LB1_WRITECHAR ; set page
MOVWF PCLATH
RLF SYS_TMP4,F
RLF SYS_TMP5,F
MOVLW 48
BTFSC STATUS,CARRY
MOVLW 49
CALL LCD_LB1_WRITECHAR
MOVLW HIGH LCD_LT5_BIN1 ; set page
MOVWF PCLATH
DECFSZ SYS_TMP6,F
GOTO LCD_LT5_BIN1
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT5_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,0
GOTO LABEL_LT5_SETFD2
BSF LT5_FD,0
GOTO LABEL_LT5_END
LABEL_LT5_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT5_FD,0
LABEL_LT5_END
;***************************************************
; LCD -> LT6
;***************************************************
; test of positiv edge
BTFSC LT6_FD,0
GOTO LABEL_LT6_SETFD
BTFSS S0,0
GOTO LABEL_LT6_SETFD
MOVLW 4
MOVWF SYS_TMP1
MOVLW 2
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
MOVFW ADC0
MOVWF SYS_TMP4
MOVFW ADC0_HI
MOVWF SYS_TMP5
BCF SYS_TMP10,0
MOVLW 2
MOVWF SYS_TMP9
MOVLW HIGH LCD_LB1_DEZO10000 ; set page
MOVWF PCLATH
CALL LCD_LB1_DEZO10000
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT6_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,0
GOTO LABEL_LT6_SETFD2
BSF LT6_FD,0
GOTO LABEL_LT6_END
LABEL_LT6_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT6_FD,0
LABEL_LT6_END
;***************************************************
; LCD -> LT7
;***************************************************
; test of positiv edge
BTFSC LT7_FD,0
GOTO LABEL_LT7_SETFD
BTFSS S0,0
GOTO LABEL_LT7_SETFD
MOVLW 4
MOVWF SYS_TMP1
MOVLW 3
MOVWF SYS_TMP2
MOVLW HIGH LCD_LB1_GOTOXY ; set page
MOVWF PCLATH
CALL LCD_LB1_GOTOXY
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
MOVFW ADC0
MOVWF SYS_TMP4
MOVFW ADC0_HI
MOVWF SYS_TMP5
LCD_LT7_BIN1
MOVLW HIGH LCD_LB1_CONVERTHEX ; set page
MOVWF PCLATH
SWAPF SYS_TMP5,W
CALL LCD_LB1_CONVERTHEX
MOVFW SYS_TMP5
CALL LCD_LB1_CONVERTHEX
SWAPF SYS_TMP4,W
CALL LCD_LB1_CONVERTHEX
MOVFW SYS_TMP4
CALL LCD_LB1_CONVERTHEX
BCF PCLATH,3 ; Page 0
BCF PCLATH,4 ; Page 0
LABEL_LT7_SETFD
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSS S0,0
GOTO LABEL_LT7_SETFD2
BSF LT7_FD,0
GOTO LABEL_LT7_END
LABEL_LT7_SETFD2
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF LT7_FD,0
LABEL_LT7_END
;***************************************************
; Timer -> TR1
;***************************************************
MOVLW 0 ; Test auf >=
SUBWF TR1_HI,W ;F-W -> W
BTFSS STATUS,ZERO
GOTO LABEL_TR1_CHECK
MOVLW 195
SUBWF TR1,W ;F-W -> W
LABEL_TR1_CHECK
BTFSS STATUS,CARRY
GOTO LABEL_TR1_ENDE
LABEL_TR1_RESET
MOVLW 0 ; Test auf >=
SUBWF TR1_HI,F ;F-W -> F
MOVLW 195
SUBWF TR1,F ;F-W -> F
BTFSS STATUS,CARRY
DECF TR1_HI,F
LABEL_TR1_SET ; toggel output
BTFSC S0,0
GOTO LABEL_TR1_CLR
BSF S0,0
GOTO LABEL_TR1_ENDE
LABEL_TR1_CLR
BCF S0,0
LABEL_TR1_ENDE
;***************************************************
; RS-FLIP-FLOP -> RS1
;***************************************************
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BTFSC S0,1
GOTO LABEL_RS1_RESET
BTFSS S0,0
GOTO LABEL_RS1_ENDE
BSF S0,2 ; Ausgang setzen
GOTO LABEL_RS1_ENDE
LABEL_RS1_RESET
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF S0,2 ; Ausgang zurücksetzen
LABEL_RS1_ENDE
;***************************************************
; GND
;***************************************************
BCF STATUS,RP0 ; Bank 0
BCF STATUS,RP1 ; Bank 0
BCF S0,1 ; immer Low
;****************************************
GOTO MAIN
TAB_LT1
RETLW 66 ; B
RETLW 73 ; I
RETLW 78 ; N
RETLW 61 ; =
RETLW 0 ; end
TAB_LT2
RETLW 68 ; D
RETLW 69 ; E
RETLW 90 ; Z
RETLW 61 ; =
RETLW 0 ; end
TAB_LT3
RETLW 72 ; H
RETLW 69 ; E
RETLW 88 ; X
RETLW 61 ; =
RETLW 0 ; end
TAB_LT4
RETLW 76 ; L
RETLW 67 ; C
RETLW 68 ; D
RETLW 45 ; –
RETLW 84 ; T
RETLW 101 ; e
RETLW 115 ; s
RETLW 116 ; t
RETLW 0 ; end
END
Yüklenecek programı çağırma, kaydetme, PIC� in içindeki programı hex olarak okuma, PIC� in içindeki programın silinmesi, PIC� deki programın protect� lenmesi vb. özellikleri içeren toolbar� lar ekrana gelir.
Ayrıca PIC içerisindeki programı Hex olarak görüntüleyen Program Memory penceresi ve EEPROM� u görüntüleyen pencere ekrana gelir.
Yukarıda Parsic� de verilen kaynak kodu, derlendikten sonra ki bu işlem için gerektiğinde Mplab vb. gibi programlar da kullanılabilir; ProPic çalıştırıldıktan sonra, dosya çağırma bölümünden, hangi sürücüye, klasöre, hangi isimle kaydedilmiş ise File menüsünden Open seçeneği ile standart windows dosya çağırma mantığı ile çağrılır. Tabii tüm bu işlemler yapılırken PIC�in PIC Board üzerinde takılı olması gerekliliğini belirtmek gerekir.
Büyük görmek için resme Tıklayın!
Program çağrıldığında aşağıdaki pencerede programın hex kodu görüntülenir.
Büyük görmek için resme Tıklayın!
Bu bölümde projelerinde PIC kullanan ve PIC kullanmak isteyen okurlarımız için değişik program seçenekleri sunarak olabilecek alternatiflerden bahsetmeye çalıştım. Gelecek aydan itibaren yine işin program tasarımı ve uygulama kısmı ile ilgili açıklamalara ve örnek programlara yer vereceğim.
İyi Çalışmalar…
Adnan IŞIK