اطلاعیه

Collapse
No announcement yet.

درایو کردن LCD 2*16 - 5*7 dot matrix با اسمبلی

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    درایو کردن LCD 2*16 - 5*7 dot matrix با اسمبلی

    به نام خدا
    با سلام خدمت دوستای گلم ، من برای راه اندازی یک lcd 2*16 - 5*7 dot matrix با استفاده از atmega8 دچار مشکل شده ام . در ضمن فقط اسمبلی بلدم . از دوستانی که میتونن کمکی بکنن ممنون میشم اگه راهنمایی کنن .
    57
    avr
    0%
    47
    8051
    0%
    10

    #2
    پاسخ : درایو کردن LCD 2*16 - 5*7 dot matrix

    کدتون رو بی زحمت بذارید تا بشه کمک کرد.
    There is nothing so practical as a good theory. — Kurt Lewin, 1951

    دیدگاه


      #3
      پاسخ : درایو کردن LCD 2*16 - 5*7 dot matrix


      کد اولی اینه:
      .include "m8def.inc"
      .def temp=r16
      .def temp1=r17
      .cseg
      .org 0
      start:
      ldi temp,low(ramend)
      out spl,temp
      ldi temp,high(ramend)
      out sph,temp
      ;
      rcall ldelay
      ;*********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x38 ;function set(1st time)
      out portb,temp
      ;
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ;
      rcall ldelay
      ;**********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x38 ;function set(2nd time)
      out portb,temp
      ;
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ;
      rcall sdelay
      ;**********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x38 ;function set(3rd time)
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy0:
      in temp,portb
      andi temp,0x80
      brne busy0
      ;***********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x38 ;function set(4th time)
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy1:
      in temp,portb
      andi temp,0x80
      brne busy1
      ;***********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x08 ;Display Off
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy2:
      in temp,portb
      andi temp,0x80
      brne busy2

      ;************************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x01 ;Clear Dispaly
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy3:
      in temp,portb
      andi temp,0x80
      brne busy3
      ;*************************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x06 ;Entry Mode Set
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy4:
      in temp,portb
      andi temp,0x80
      brne busy4
      ;************************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x0f ;Display On
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy5:
      in temp,portb
      andi temp,0x80
      brne busy5
      ;***********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x80 ;cursor home
      out portb,temp
      ; Generate Enable Pulse
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ; Busy Flag Check
      ldi temp,0x00
      out ddrb,temp
      sbi portd,1
      busy7:
      in temp,portb
      andi temp,0x80
      brne busy7
      ;***********************************
      here:
      rjmp here
      ;
      ldelay:
      clr temp
      del1: inc temp
      brne del1
      inc temp1
      brne del1
      ret
      ;
      sdelay:
      clr temp

      del2: inc temp
      brne del2
      ret


      اینم دومین کد

      .include "m8def.inc"
      .def temp=r16
      .def auxreg=r17
      .cseg
      .org 0
      ; portb as data and instruction bus
      ; portd.0 as RS
      ; portd.1 as R/W
      ; portd.2 as EN
      start:
      ldi temp,low(ramend) ;Setting Stack Pointer
      out spl,temp
      ldi temp,high(ramend)
      out sph,temp
      ldi temp,0x07
      out ddrb,temp
      ;
      rcall ldelay
      ;*********************************
      ldi temp,0xff
      out ddrb,temp
      ldi temp,0x07
      out ddrd,temp
      ;
      cbi portd,0
      cbi portd,1
      ldi temp,0x3f ;function set(1st time)
      out portb,temp
      ;
      nop
      sbi portd,2
      nop
      nop
      cbi portd,2
      ;
      rcall ldelay
      ;
      rcall ldelay
      ;
      ;
      ldi temp,0x3f
      rcall command
      ldi temp,0x3f
      rcall command
      ldi temp,0x3f
      rcall command
      ldi temp,0x0e
      rcall command
      ldi temp,0x01
      rcall command
      ldi temp,0x07
      rcall command
      ldi temp,0x80
      rcall command
      ldi temp,'n'
      rcall data_disp
      ldi temp,'o'
      rcall data_disp
      ;
      here:
      rjmp here
      ;
      command:
      rcall ready
      ldi auxreg,0xff
      out ddrb,auxreg
      out portb,temp
      cbi portd,0
      cbi portd,1
      sbi portd,2
      nop
      cbi portd,2
      ret
      ;
      data_disp:
      rcall ready
      ldi auxreg,0xff
      out ddrb,auxreg
      out portb,temp
      sbi portd,0
      cbi portd,1
      sbi portd,2
      nop
      cbi portd,2
      ret
      ;
      ready:
      ldi auxreg,0x00
      out ddrb,auxreg
      cbi portd,0
      sbi portd,1
      busy:
      sbi portd,2
      nop
      cbi portd,2
      in auxreg,portb
      andi auxreg,0x80
      brne busy
      ret
      ;
      ldelay:
      clr temp
      clr auxreg
      del1:
      inc temp
      brne del1
      inc auxreg
      brne del1
      ret
      ;







      دیدگاه


        #4
        پاسخ : درایو کردن LCD 2*16 - 5*7 dot matrix

        با سلام
        من که اسمبلی بلد نیستم ولی این کار با سی راحت میشه انجامش داد
        الان وقت ندارم
        24 واحد برداشتم نمیتونم زیاد کار کنم

        دیدگاه

        لطفا صبر کنید...
        X