Picproje Elektronik Sitesi

DERLEYİCİLER => PIC Assembly => Konuyu başlatan: Extreme - 23 Ekim 2014, 21:24:36

Başlık: Lcd sürme uygulaması
Gönderen: Extreme - 23 Ekim 2014, 21:24:36
Merhaba arkadaşlar,

Assembly dilinde lcd'de basit bir yazılım yapmak istiyorum.

aşağıdaki kodları hazırladım.

proteusda görüntü alamadım.

Yardımcı olursanız çok sevinirim

proteus schematic ve yazılım aşağıdaki dosyada mevcuttur

https://www.dropbox.com/s/atom6te0m0bd35w/Lcd.rar?dl=0 (https://www.dropbox.com/s/atom6te0m0bd35w/Lcd.rar?dl=0)



;**************************************************************************
;***** \ Date : 19 October 2014
;***** \ Writen by :
;***** \ Program : lcd.asm
;***** \ Ams. by : MPLAB IDE version 8.92
;***** \ Processor : MICROCHIP pic16f877A
;***** \ Device : Basic bread board
;**************************************************************************

LIST P=16F877A
INCLUDE "P16F877A.INC"

;****------Değişkenler-----------*******************************************

SAYAC1 EQU H'0C'
SAYAC2 EQU H'0D'



CLRF PORTB
BSF STATUS,5
CLRF TRISB
CLRF TRISA
BCF STATUS,5


BASLA
MOVLW H'01'
CALL KOMUTYAZ
MOVLW H'30'
CALL KOMUTYAZ
MOVLW H'0C'
CALL KOMUTYAZ
DEVAM
CALL SATIRYAZ
GOTO DEVAM


KOMUTYAZ
BCF PORTA,1
MOVWF PORTB
BSF PORTA,0
CALL GECIKME
BCF PORTA,0
RETURN


VERIYAZ
BSF PORTA,1
MOVWF PORTB
BSF PORTA,0
CALL GECIKME
BCF PORTA,0
RETURN


SATIRYAZ
MOVLW 'D'
CALL VERIYAZ
MOVLW 'E'
CALL VERIYAZ
MOVLW 'N'
CALL VERIYAZ
MOVLW 'E'
CALL VERIYAZ
MOVLW 'M'
CALL VERIYAZ
MOVLW 'E'
RETURN


GECIKME
MOVLW H'05'
MOVWF SAYAC1
D1
MOVLW H'FF'
MOVWF SAYAC2
D2
DECFSZ SAYAC2,F
GOTO D2
DECFSZ SAYAC1,F
GOTO D1
RETURN



END



(http://s23.postimg.cc/sjg1qw5gn/schematic.jpg) (http://postimg.cc/image/sjg1qw5gn/)
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Kabil ATICI - 23 Ekim 2014, 21:31:27
LCD başlamamış ki.
3 tane 0x30 komut ile gönderilen ve gecikme olan bölüm..
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Extreme - 23 Ekim 2014, 21:50:19
Yani nereyi değiştirmek lazım hocam ?

Basitçe en basitinden sürsem mantığını anlamak için yeterli.
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Kabil ATICI - 23 Ekim 2014, 22:11:39
http://www.hantronix.com/files/down/char-mod.pdf (http://www.hantronix.com/files/down/char-mod.pdf)
asm farklı isede temel olarak ne yapılması gerektiği konusunda bir fikir verebilir.
Sadece tek fark burada RW ucuda kullanılmakta. (meşgul durumu testi için)
Siz bunu zaman gecikmeleri kullanarak sağlamaktasınız.

Buradaki kodu değişik platformlarda 2000 yılından beri kullanıyorum. Hiç sıkıntı çıkarmadı..
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: RaMu - 24 Ekim 2014, 04:15:32
Denemelerini Dinçer in lcd simulatörğ üzerinden yapabilirsin,
birşey indirmene gerek yok, hatta sayfayı kaydedip net olmadanda kullanabiliyorduk sanırım.
http://www.dinceraydin.com/djlcdsim/djlcdsim.html (http://www.dinceraydin.com/djlcdsim/djlcdsim.html)

Eskiden hazırladığım lcd ile ilgili asmciler için bir belge var,
bazı yerleri nlatmamışım ama faydalı bilgiler var;
https://www.dropbox.com/s/trq22u7q55j5z3v/2X16%20LCD%20giri%C5%9F.rar?dl=0 (https://www.dropbox.com/s/trq22u7q55j5z3v/2X16%20LCD%20giri%C5%9F.rar?dl=0)

Buda çalışan örnek kod, proteus simulasyon
8bit mod
https://www.dropbox.com/s/yymsod3ag4hx7pu/1_LCD_ad_soyad.rar?dl=0 (https://www.dropbox.com/s/yymsod3ag4hx7pu/1_LCD_ad_soyad.rar?dl=0)
şifre: RaMu

4 bit mod
https://www.dropbox.com/s/qd2aef97pqmyeh5/1_LCD_ad_soyad2_4bit.rar?dl=0 (https://www.dropbox.com/s/qd2aef97pqmyeh5/1_LCD_ad_soyad2_4bit.rar?dl=0)
şifre: RaMu
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Extreme - 24 Ekim 2014, 19:55:24
Assembly e yeni başlayan arkadaşlar için çok güzel lcd uygulamaları.

Herkese teşekkürler.

Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Extreme - 01 Kasım 2014, 00:25:52
RaMu Hocam, elinize sağlık.



ERRORLEVEL -203,-205,-302
INCLUDE "P16F877A.INC"
LIST P=16F877A
__CONFIG _CP_OFF&_WDT_OFF&_XT_OSC &_PWRTE_ON&_BODEN_OFF&_DEBUG_OFF &_LVP_OFF


SYC1 EQU 20H
SYC2 EQU 21H
SYC3 EQU 22H

TEMP EQU 23H


RS EQU 1
E EQU 0


ORG 00h

call SARTLA
call LCD_SARTLA


;-------------------------------ANA PROGRAM
MOVLW 'R'
CALL VERI_YAZ
MOVLW 'a'
CALL VERI_YAZ
MOVLW 'M'
CALL VERI_YAZ
MOVLW 'u'
CALL VERI_YAZ


MOVLW 0C0H ;2. SATIRA GEC
CALL KOMUT_YAZ

MOVLW 'R'
CALL VERI_YAZ
MOVLW 'a'
CALL VERI_YAZ
MOVLW 'M'
CALL VERI_YAZ
MOVLW 'u'
CALL VERI_YAZ
MOVLW 'T'
CALL VERI_YAZ
MOVLW 'e'
CALL VERI_YAZ
MOVLW 'K'
CALL VERI_YAZ



GOTO $
;-------------------------------ANA PROGRAM










;-----------------ALTPROGRAMLAR

;-----------------GIRIS CIKIS SARTLAMA
SARTLA clrf PORTB
CLRF PORTC
BANKSEL TRISC
CLRF TRISC
CLRF TRISB
BANKSEL PORTB
BCF PORTC,RS
BCF PORTC,E
CLRF PORTB
RETURN
;------------------GIRIS CIKIS SARTLAMA



;------------------LCD SARTLAMA
LCD_SARTLA NOP

LCDKUR NOP
CALL D_50MS ;ÖNCELİKLE 3 DEFA 00H GONDERILIR, HERBIRININ ARASINDA VE EN BASTA 50_MS BEKLENIR
MOVLW 00H ;1
CALL KOMUT_YAZ
CALL D_50MS
MOVLW 00H ;2
CALL KOMUT_YAZ
CALL D_50MS
MOVLW 00H ;3
CALL KOMUT_YAZ
CALL D_50MS



            MOVLW  02H      ;KURSOR Ü BAŞA AL    ;BU SIRALAMA ONEMLI
            CALL KOMUT_YAZ ;YOKSA ISISTE CALISMAZ
            MOVLW  28H      ;2 SATIR, 5*7 KARAKTER,  4 BİT MOD  (38H = 8 BIT MOD)
            CALL KOMUT_YAZ
            MOVLW  0FH      ;DISPLAY AÇIK  KURSOR AÇIK KURSOR YAN-SÖN
            CALL KOMUT_YAZ
            MOVLW  06H      ;06=HER KARAKTER YAZMADA KURSÖR SAĞA KAYACAK EKRAN SABİT
            CALL KOMUT_YAZ


            MOVLW  01H      ;DISPLAY TEMİZLE
CALL KOMUT_YAZ




RETURN
;------------------LCD SARTLAMA












;------------------KOMUT YAZDIRMA ALTPROGRAMI
KOMUT_YAZ MOVWF TEMP ;VERIYI ALT--UST 4 BIT AYIRIP GONDERMEK ICIN
BCF PORTC,RS
BSF PORTC,E
MOVWF PORTB ;ONCE UST 4 BIT GIDER
CALL D_200US
BCF PORTC,E
CALL D_50MS ;LCD KOMUTU ISLERKEN MESGUL OLACAK, ARDARDA KOMUT
;YAZDIRILMAK ISTENIRSE DIYE BEKLENMELI

BSF PORTC,E
SWAPF TEMP,W
MOVWF PORTB ;SONRA ALT 4 BIT GIDER
CALL D_200US
BCF PORTC,E
CALL D_50MS ;LCD KOMUTU ISLERKEN MESGUL OLACAK, ARDARDA KOMUT
;YAZDIRILMAK ISTENIRSE DIYE BEKLENMELI





RETURN
;------------------KOMUT YAZDIRMA ALTPROGRAMI

;------------------VERI YAZDIRMA ALTPROGRAMI
VERI_YAZ MOVWF TEMP ;VERIYI UST-ALT 4 BIT AYIRIP GONDERMEK ICIN
BSF PORTC,RS
BSF PORTC,E
MOVWF PORTB ;ONCE UST 4 BIT GIDER
CALL D_200US ;
BCF PORTC,E
CALL D_50MS ;LCD VERI YAZARKEN MESGUL OLACAK, ARDARDA VERI
;YAZDIRILMAK ISTENIRSE DIYE BEKLENMELI

BSF PORTC,E
SWAPF TEMP,W
MOVWF PORTB ;SONRA ALT 4 BIT GIDER
CALL D_200US ;
BCF PORTC,E
CALL D_50MS ;LCD VERI YAZARKEN MESGUL OLACAK, ARDARDA VERI
;YAZDIRILMAK ISTENIRSE DIYE BEKLENMELI




RETURN
;------------------VERI YAZDIRMA ALTPROGRAMI


;------------------200 MIKROSANIYE BEKLEME
D_200US MOVLW D'50' ;(1 MS ICIN 250 YAZILMALI) 200  MIKROSANIYE YETERLI
MOVWF SYC3
LOOP3 NOP
DECFSZ SYC3,F
GOTO LOOP3
RETURN
;------------------200 MIKROSANIYE BEKLEME



;------------------50 MILISANIYE BEKLEME
D_50MS MOVLW D'50'
MOVWF SYC1
LOOP1 MOVLW D'250'
MOVWF SYC2

LOOP2 NOP
DECFSZ SYC2, F
GOTO LOOP2

DECFSZ SYC1,F
GOTO LOOP1
RETURN
;------------------50 MILISANIYE BEKLEME



END


Yazılım benim için temel oluşturdu fakat benim

org 0x1500
DA " Current          A",H'000'


Bu tip bir yazı yazdırmam lazım ekrana bu tanımlanmayı en başta yapmış yazar. sonra o boşluğu elindeki değişkenle değişiyor yardımcı olursanız sevinirim.
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: RaMu - 03 Kasım 2014, 15:04:45
Pic için DA diye bir komut yok,
bu derleyici ile ilgili birşey,
DA yı tam hatırlamıyorum ama DT yi hatırlıyorum,
DA kullanımını araşırırsan bu işi çözersin,
muhtemelen,
DT "biz"
dediğinde
retlw 'b';
retlw 'i';
retlw 'z';

oluyor, buna benzer birşey,
bu kısmı bulduktan sonrası kolay zaten.

Elindeki DA kullanılan programda
disasembly listing kısmına gidip
(mplab da view > disassembly listing)
DA nın olduğu yere bakarsan
açılımını görebilirsin.
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: Extreme - 17 Kasım 2014, 11:26:29
RaMu hocam, teşekkürler işimi fazlasıyla gördü.
Başlık: Ynt: Lcd sürme uygulaması
Gönderen: ido2323 - 27 Kasım 2014, 22:49:03
Buda benden promosyon olsun (2x16 lcd pic18f4550 ile sürme dahili osilatör kullanılmıştır 8 mhz)


         list   p=18f4550            ; kullan?lan pic tan?t
#include "p18F4550.inc"

; CONFIG1L
  CONFIG  PLLDIV = 1            ; PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
  CONFIG  CPUDIV = OSC1_PLL2    ; System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
  CONFIG  USBDIV = 1            ; USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)

; CONFIG1H
  CONFIG  FOSC = INTOSC_HS             ; Oscillator Selection bits (HS oscillator (HS))
  CONFIG  FCMEN = OFF           ; Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  CONFIG  IESO = OFF            ; Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

; CONFIG2L
  CONFIG  PWRT = OFF            ; Power-up Timer Enable bit (PWRT enabled)
  CONFIG  BOR = ON              ; Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
  CONFIG  BORV = 3              ; Brown-out Reset Voltage bits (Minimum setting)
  CONFIG  VREGEN = OFF          ; USB Voltage Regulator Enable bit (USB voltage regulator disabled)

; CONFIG2H
  CONFIG  WDT = OFF             ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
  CONFIG  WDTPS = 32768         ; Watchdog Timer Postscale Select bits (1:32768)

; CONFIG3H
  CONFIG  CCP2MX = ON           ; CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
  CONFIG  PBADEN = OFF           ; PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
  CONFIG  LPT1OSC = OFF         ; Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
  CONFIG  MCLRE = ON            ; MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)

; CONFIG4L
  CONFIG  STVREN = ON           ; Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  CONFIG  LVP = OFF              ; Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
  CONFIG  ICPRT = OFF           ; Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit (ICPORT disabled)
  CONFIG  XINST = OFF           ; Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

; CONFIG5L
  CONFIG  CP0 = OFF             ; Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
  CONFIG  CP1 = OFF             ; Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
  CONFIG  CP2 = OFF             ; Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
  CONFIG  CP3 = OFF             ; Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

; CONFIG5H
  CONFIG  CPB = OFF             ; Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
  CONFIG  CPD = OFF             ; Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

; CONFIG6L
  CONFIG  WRT0 = OFF            ; Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
  CONFIG  WRT1 = OFF            ; Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
  CONFIG  WRT2 = OFF            ; Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
  CONFIG  WRT3 = OFF            ; Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

; CONFIG6H
  CONFIG  WRTC = OFF            ; Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
  CONFIG  WRTB = OFF            ; Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
  CONFIG  WRTD = OFF            ; Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

; CONFIG7L
  CONFIG  EBTR0 = OFF           ; Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
  CONFIG  EBTR1 = OFF           ; Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
  CONFIG  EBTR2 = OFF           ; Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
  CONFIG  EBTR3 = OFF           ; Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

; CONFIG7H
  CONFIG  EBTRB = OFF           ; Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

;============================================================

;********** SOL EKRANI SEÇMEYE YARAYAN MAKRO*********
CSA MACRO
BSF CS1
BCF CS2
ENDM
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;***********SA? EKRANI SEÇMEYE YARAYAN MAKRO**********
CSB MACRO
BCF CS1
BSF CS2
ENDM
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    #define LCD_D7   LATD,0      ;
    #define LCD_D6   LATD,6      ;
    #define LCD_D5   LATD,2      ;
    #define LCD_D4   LATD,3      ;
    #define LCD_RS   LATD,5      ;
    #define LCD_E    LATD,4      ;
;============================================================

kolon_ind equ 20h;
tablo_ind equ 21h;
sayac1      equ 22h
sayac2      equ 23h
LCD_CS equ 25h;
LCDTmp    equ 26h;
LCDINIT equ 27h;
LCD_DATA equ 28h;
COUNTER1 equ 29h;
COUNTER2 equ 2Ah;
COUNTER3 equ 2Bh;
TEMP equ 2Ch;
satir equ 0x22
DALLAN equ 30h

        ORG     0X0000            ; ba?lang?ç vektörü
; clrf    PCLATH            ; pc sayac?n?n ;yüksek bitini s?f?rla
  goto    main              ; ana programa ;dallan

;
;
;
;
;
;
ORG     0X0020
main
;port tan?mlamalar? yap?l?yor.
movlw b'11111111'
movwf OSCCON

MOVLW 07h ; Turn off
MOVWF CMCON ; comparator
MOVLW 0Fh ; Configure A/D
MOVWF ADCON1 ; for digital inputs



CLRF LATD
MOVLW 0X00
MOVWF TRISD

call LCDOPEN ; Initialize LCD
;movlw 0x05
call LCDADD
movlw 'S'
call LCDSEND
movlw   'Y'
call LCDSEND
movlw 'S'
call LCDSEND
movlw 'T'
call LCDSEND
movlw 'E'
call LCDSEND
movlw 'M'
call LCDSEND
ASD
GOTO ASD

LCDOPEN

bcf LCD_RS ; Set command mode
bcf LCD_E
bsf LCD_D4
bsf LCD_D5
bcf LCD_D6
bcf LCD_D7
call PULSE

bcf LCD_D4
call PULSE

; Function set
; Format: xxxDNFxx   D: 1= 8-bit, 0= 4-bit (use 4-bit!)
movlw b'00101000' ; N: 1= 2 lines, 0= 1 line
call LCDSEND ; F: 1= 5x10 font, 0= 5x8 font

; Display control
; Format: xxxxxDCB   D: Display on(1)/0ff(0)
movlw b'00001111' ; C: Cursor on(1)/0ff(0)
call LCDSEND ; B: Blink on(1)/0ff(0)

; Entry mode set
; Format: xxxxxxIS   I: 1= Increment counter, 0= Decrement counter
movlw b'00000110' ; S: 1= "Accompanies display shift"
call LCDSEND

; Cursor or display shift
; Format: xxxxSRxx   S: 1= Display shift, 0= Cursor move
movlw b'00010000' ; R: 1= Shift right, 0= Shift left
call LCDSEND


movlw b'00000001' ; Clear screen
call LCDSEND

RETURN

LCDADD
;bcf LCD_RS ; Command mode
;movlw b'1000' ; Goto DDRAM adress
;call LCDSEND
bsf LCD_RS ; Data mode
call Pause ; Takes a couple of ms
   
RETURN

LCDSEND ; Sends character in W to lcd. Does not alter RS line!
movwf LCDTmp
bcf LCD_D4
bcf LCD_D5
bcf LCD_D6
bcf LCD_D7


btfsc LCDTmp, 7
bsf LCD_D7
btfsc LCDTmp, 6
bsf LCD_D6
btfsc LCDTmp, 5
bsf LCD_D5
btfsc LCDTmp, 4
bsf LCD_D4
call PULSE



bcf LCD_D4
bcf LCD_D5
bcf LCD_D6
bcf LCD_D7


btfsc LCDTmp, 3
bsf LCD_D7
btfsc LCDTmp, 2
bsf LCD_D6
btfsc LCDTmp, 1
bsf LCD_D5
btfsc LCDTmp, 0
bsf LCD_D4
call PULSE

return
;-------------------------------------------------

PULSE ; Pulse Enable.
bsf LCD_E
call Pause
; 1 instruction @10MHz = 400ns
bcf LCD_E
return

Pause
movlw h'14'
   MOVWF sayac1

DONGU11
   movlw h'ff'
   MOVWF sayac2

DONGU12
   DECFSZ sayac2,F ;sayac2'nin de?erini 1 azalt s?f?r olursa "DECFSZ sayac1,F" komutuna atla
   GOTO DONGU12
   DECFSZ sayac1,F ;sayac1'nin de?erini 1 azalt s?f?r olursa "DECFSZ sayac1,F" döngüden ç?k
   GOTO DONGU11
RETURN

;################################################


end