Teade

Collapse

Foorumi reeglid.

Foorumi reeglistik on uuendatud. Palume tutvuda ja arvesse võtta.
See more
See less

Mis on LCD koodis valesti. pic 16f628

Collapse
X
 
  • Filter
  • Kellaaeg
  • Show
Clear All
new posts

    #16
    Vs: Mis on LCD koodis valesti. pic 16f628

    Tuginesin http://www.epemag.wimborne.co.uk/pictutorial.pdf lehel antud õpetusele. Seal on näha, et kui jätta ADFM nulliga võrduma, siis pannakse alumised bitid ADRESH registrisse, aga jah, mis süsteemiga neid bitte seal siis liigutatkse jääb arusaamatuks. Kui pöördusin niisama ADRESL poole, siis hakati seal ka bitte kuskilt X kohast loendama. Kui ADFM=1, siis sai juba normaalse nähtuse ADRESL st. Tänud nõuande eest.

    Comment


      #17
      Vs: Mis on LCD koodis valesti. pic 16f628

      ADFM määrab, kuhupoole bitid lükatakse. Ehk seda, milline register sisaldab täisbaiti.
      "Küljendus" paremale tähendab, et ADRESL sisaldab bitte 0..7, kõrgemad on ADRESH-s alates bitist 8. Seega on ADRESH ülemised 4 bitti nullid.
      Nihe vasakule tähendab, et muundi 10-st bitist on 8 vanemat registris ADRESH (bitt 10, bitt9....bitt3) ja noorimad jäävad ADRESL-i nihutatuna tema vasaku otsa poole. S.t. muundi bitt2 asub registri bitis 7 jne. Nihutatakse seega kogu 10-t bitti.
      - Vend Hieronymus tunneb Motorola toodete nimekirja kõige paremini, las tema ütleb.
      - Motorola poolt loodud kiipide hulgas ei ole teda üles tähendatud. - Tähendab: ta on Intelist!

      Comment


        #18
        Vs: Mis on LCD koodis valesti. pic 16f628

        Tänan selgituse eest, nüüd ise uuesti uurima hakates tundub nagu selgem. Mis võib põhjustada selle, et ma ei saa LCD le aadressist 88h ja edasi määrata sümboleid. Nimelt siis saadan lcdle vastava DDRAM aadressi ning siis CLOCKin tsümboli, aga ei ilmu midagi ekraanile. Samas, kui määran aadressiks alla 88h, siis kõik ok. Displei peaks korras olema, sest LCD ise on sinna kirjutanud küll. LCD konf koodide seletuses ei olnud küll midagi sellist, mis niisugust nähtust võiks esile kutsuda. Kasutan 4bit ülekandel, 1x16 LCD´d.
        Kui miski X nurga all displeid vaadata, siis on näha et need nö ruudud (8tk) kus kirja on võimalik kuvada, on pisut tugevama tooniga, järgmised kaheksa on vaevunähtavad.
        viimati muutis kasutaja Marko238; 01 m 2007, 22:11.

        Comment


          #19
          Vs: Mis on LCD koodis valesti. pic 16f628

          Kas saadad sümbolit koodiga 0x88 ? Seda ei pruugi too LCD tundagi. Või proovid saata mingi muu sümboli rea aadressile 0x88? See võib olla tööalast väljas või üldse puududa.
          - Vend Hieronymus tunneb Motorola toodete nimekirja kõige paremini, las tema ütleb.
          - Motorola poolt loodud kiipide hulgas ei ole teda üles tähendatud. - Tähendab: ta on Intelist!

          Comment


            #20
            Vs: Mis on LCD koodis valesti. pic 16f628

            Toon näite:
            Kood:
            movlw 08h       ;määran displeil A tähe aadressiks 80h, mis on siis esimene 
            movwf PORTB   ;segment. 
            call CLOCK        ;Clock on lcd enda data jaoks, RS=0 E=1, 4 biti kaupa
            movlw 00h
            movwf PORTB
            call CLOCK
            call delay10ms
            call tahtA         ;tahtA klokitakse varemmmääratud aadressile RS=1 E=1, 
            call dealy10ms   ;jällegi 4 biti kaupa.
            
            movlw 08h       ;Tahan jätta mõned tähekohad vahele ja kirjutada 
            movwf PORTB    ;11. segmendile. 
            call CLOCK
            movlw 0Ah
            movwf PORTB
            call CLOCK
            call delay10ms
            call tahtA         ;Sama täht, saadetakse sama moodi, aga ei kuvata.
            call dealy10ms
            LCD l on vana hea hitachi kontroller ja segmentide aadressid on ka kõikides õpetustes, mida ma lugema olen saanud, samad olnud.
            http://www.codeproject.com/csharp/cspplcds.asp

            Comment


              #21
              Vs: Mis on LCD koodis valesti. pic 16f628

              Ma arvan, et aadress pole "nähtavas" alas. Vaata siia: http://ouwehand.net/~peter/lcd/lcd0.shtml#visible_ddram
              - Vend Hieronymus tunneb Motorola toodete nimekirja kõige paremini, las tema ütleb.
              - Motorola poolt loodud kiipide hulgas ei ole teda üles tähendatud. - Tähendab: ta on Intelist!

              Comment


                #22
                Vs: Mis on LCD koodis valesti. pic 16f628

                ;LCD text demo - 4 bit mode
                ;Nigel Goodwin 2002

                LIST p=16F628 ;tell assembler what chip we are using
                include "P16F628.inc" ;include the defaults for the chip
                ERRORLEVEL 0, -302 ;suppress bank selection messages
                __config 0x3D18 ;sets the configuration settings (oscillator type etc.)




                cblock 0x20 ;start of general purpose registers
                count ;used in looping routines
                count1 ;used in delay routine
                counta ;used in delay routine
                countb ;used in delay routine
                tmp1 ;temporary storage
                tmp2
                templcd ;temp store for 4 bit mode
                templcd2
                endc

                LCD_PORT Equ PORTA
                LCD_TRIS Equ TRISA
                LCD_RS Equ 0x04 ;LCD handshake lines
                LCD_RW Equ 0x06
                LCD_E Equ 0x07

                org 0x0000

                movlw 0x07
                movwf CMCON ;turn comparators off (make it like a 16F84)

                Initialise clrf count
                clrf PORTA
                clrf PORTB



                SetPorts bsf STATUS, RP0 ;select bank 1
                movlw 0x00 ;make all pins outputs
                movwf LCD_TRIS
                bcf STATUS, RP0 ;select bank 0

                call Delay100 ;wait for LCD to settle


                call LCD_Init ;setup LCD


                clrf count ;set counter register to zero
                Message movf count, w ;put counter value in W
                call Text ;get a character from the text table
                xorlw 0x00 ;is it a zero?
                btfsc STATUS, Z
                goto NextMessage
                call LCD_Char
                call Delay255
                incf count, f
                goto Message

                NextMessage call LCD_Line2 ;move to 2nd row, first column

                clrf count ;set counter register to zero
                Message2 movf count, w ;put counter value in W
                call Text2 ;get a character from the text table
                xorlw 0x00 ;is it a zero?
                btfsc STATUS, Z
                goto EndMessage
                call LCD_Char
                incf count, f
                goto Message2

                EndMessage

                Stop goto Stop ;endless loop




                ;Subroutines and text tables

                ;LCD routines

                ;Initialise LCD
                LCD_Init movlw 0x20 ;Set 4 bit mode
                call LCD_Cmd

                movlw 0x28 ;Set display shift
                call LCD_Cmd

                movlw 0x06 ;Set display character mode
                call LCD_Cmd

                movlw 0x0d ;Set display on/off and cursor command
                call LCD_Cmd

                call LCD_Clr ;clear display

                retlw 0x00

                ; command set routine
                LCD_Cmd movwf templcd
                swapf templcd, w ;send upper nibble
                andlw 0x0f ;clear upper 4 bits of W
                movwf LCD_PORT
                bcf LCD_PORT, LCD_RS ;RS line to 0
                call Pulse_e ;Pulse the E line high

                movf templcd, w ;send lower nibble
                andlw 0x0f ;clear upper 4 bits of W
                movwf LCD_PORT
                bcf LCD_PORT, LCD_RS ;RS line to 0
                call Pulse_e ;Pulse the E line high
                call Delay5
                retlw 0x00

                LCD_CharD addlw 0x30
                LCD_Char movwf templcd
                swapf templcd, w ;send upper nibble
                andlw 0x0f ;clear upper 4 bits of W
                movwf LCD_PORT
                bsf LCD_PORT, LCD_RS ;RS line to 1
                call Pulse_e ;Pulse the E line high

                movf templcd, w ;send lower nibble
                andlw 0x0f ;clear upper 4 bits of W
                movwf LCD_PORT
                bsf LCD_PORT, LCD_RS ;RS line to 1
                call Pulse_e ;Pulse the E line high
                call Delay5
                retlw 0x00

                LCD_Line1 movlw 0x80 ;move to 1st row, first column
                call LCD_Cmd
                retlw 0x00

                LCD_Line2 movlw 0xc0 ;move to 2nd row, first column
                call LCD_Cmd
                retlw 0x00

                LCD_Line1W addlw 0x80 ;move to 1st row, column W
                call LCD_Cmd
                retlw 0x00

                LCD_Line2W addlw 0xc0 ;move to 2nd row, column W
                call LCD_Cmd
                retlw 0x00

                LCD_CurOn movlw 0x0d ;Set display on/off and cursor command
                call LCD_Cmd
                retlw 0x00

                LCD_CurOff movlw 0x0c ;Set display on/off and cursor command
                call LCD_Cmd
                retlw 0x00

                LCD_Clr movlw 0x01 ;Clear display
                call LCD_Cmd
                retlw 0x00

                LCD_HEX movwf tmp1
                swapf tmp1, w
                andlw 0x0f
                call HEX_Table
                call LCD_Char
                movf tmp1, w
                andlw 0x0f
                call HEX_Table
                call LCD_Char
                retlw 0x00

                Delay255 movlw 0xff ;delay 255 mS
                goto d0
                Delay100 movlw d'100' ;delay 100mS
                goto d0
                Delay50 movlw d'50' ;delay 50mS
                goto d0
                Delay20 movlw d'20' ;delay 20mS
                goto d0
                Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz clock)
                d0 movwf count1
                d1 movlw 0xC7 ;delay 1mS
                movwf counta
                movlw 0x01
                movwf countb
                Delay_0
                decfsz counta, f
                goto $+2
                decfsz countb, f
                goto Delay_0

                decfsz count1 ,f
                goto d1
                retlw 0x00

                Pulse_e bsf LCD_PORT, LCD_E
                nop
                bcf LCD_PORT, LCD_E
                retlw 0x00

                ;end of LCD routines

                HEX_Table ADDWF PCL , f
                RETLW 0x30
                RETLW 0x31
                RETLW 0x32
                RETLW 0x33
                RETLW 0x34
                RETLW 0x35
                RETLW 0x36
                RETLW 0x37
                RETLW 0x38
                RETLW 0x39
                RETLW 0x41
                RETLW 0x42
                RETLW 0x43
                RETLW 0x44
                RETLW 0x45
                RETLW 0x46


                Text addwf PCL, f
                retlw 'H'
                retlw 'e'
                retlw 'l'
                retlw 'l'
                retlw 'o'
                retlw 0x00

                Text2 ADDWF PCL, f
                RETLW 'R'
                RETLW 'e'
                RETLW 'a'
                RETLW 'd'
                RETLW 'y'
                RETLW '.'
                RETLW '.'
                RETLW '.'
                RETLW 0x00


                end

                Comment

                Working...
                X