init lcd en 4 bit
Répondre à la discussion
Affichage des résultats 1 à 11 sur 11

init lcd en 4 bit



  1. #1
    sdow

    init lcd en 4 bit


    ------

    salut

    j'ai un lcd 4x20 44780h . Mon problème est : je ne suis pas cabaple de initialiser correctement mon LCD en 4 bit . en 8bit il fonction très bien

    mais en 4 il ne veux rien savoir . pouvez vous m'aider : voila mon code




    void Init_Lcd_4bit()
    {

    VarSend = 0x30;
    Lcd_Send(VarSend);

    VarSend = 0x30;
    Lcd_Send(VarSend);
    VarSend = 0x30;
    Lcd_Send(VarSend);
    VarSend = 0x30;
    Lcd_Send(VarSend);
    VarSend = 0x20;
    Lcd_Send(VarSend);
    VarSend = 0x20;
    Lcd_Send(VarSend);
    VarSend = 0x80;
    Lcd_Send(VarSend);
    VarSend = 0x00;
    Lcd_Send(VarSend);
    VarSend = 0xb0;
    Lcd_Send(VarSend);
    VarSend = 0x00;
    Lcd_Send(VarSend);
    VarSend = 0x10;
    Lcd_Send(VarSend);
    VArSend = 0x00;
    Lcd_Send(VarSend); // poids faible
    VarSend = 0x60;
    Lcd_Send(VarSend);




    }


    void SendCommand(char VarSend)
    {

    LCD_DATA_PORT= VarSend; /* masquage des poids faible*/

    bit_set(LCD_DATA_PORT,10); /* mise à 1 de E (validation)*/

    delay_ms(5);
    /* delai de 450 ns a respecter ... */
    bit_clear(LCD_DATA_PORT,10); /* mise à 0 de E*/
    delay_ms(5);
    }


    void Lcd_Char(char CharSend)
    { // envoi d un charactere à l écran
    char VarToSend; // variable interne à la fonction
    VarToSend= CharSend & 0xF0; // masquage des poids faible
    VarToSend= VarToSend +0x01; // RS =1
    LCD_DATA_PORT= VarToSend; // masquage des poids faible
    bit_set(LCD_DATA_PORT,1); // mise à 1 de E (validation)

    delay_ms(10);

    bit_clear(LCD_DATA_PORT,2); // mise à 0 de E
    delay_ms(10);
    VarToSend = CharSend <<4; // decalage poids faible
    VarToSend = VarToSend & 0xF0; // masquage poids faible
    VarToSend = VarToSend +1; // position de RS=1
    LCD_DATA_PORT= VarToSend; // masquage des poids faible
    bit_set(LCD_DATA_PORT,1); // mise à 1 de E (validation)
    delay_ms(10);
    bit_clear(LCD_DATA_PORT,1); // mise à 0 de E
    delay_ms(10);

    }

    -----

  2. #2
    freepicbasic

    Re : init lcd en 4 bit

    le 4 bits connectés doivent être les poids forts DB7-DB4.

    A partir du moment ou on envoie 0X20 mode 4 bits il faut changer de procédure
    Lcd_Send() envoie 8 bits je suppose , alors il faut envoyer 0x00 en plus pour les ordres suivants
    A+, pat

  3. #3
    Seb.26

    Re : init lcd en 4 bit

    Citation Envoyé par freepicbasic Voir le message
    A partir du moment ou on envoie 0X20 mode 4 bits il faut changer de procédure
    Lcd_Send() envoie 8 bits je suppose , alors il faut envoyer 0x00 en plus pour les ordres suivants
    AMA, Lcd_Send() envois bien 8bits, mais sur un bus 4bits ( envois en 2 fois )

    sdow : Tu pourrais mettre un lien vers la datasheet du controleur de ton LCD stp ... ça serait plus facile pour t'aider ...

  4. #4
    sdow

    Re : init lcd en 4 bit

    le datasheet :http://www.tranzistoare.ro/datasheets/400/81271_DS.pdf

    j'ai tout essayer l'devient vide mais aucune lettre d'afficher ,

  5. A voir en vidéo sur Futura
  6. #5
    freepicbasic

    Re : init lcd en 4 bit

    AMA, Lcd_Send() envois bien 8bits, mais sur un bus 4bits ( envois en 2 fois )
    Si l'envoie en 2 fois , alors le début est faux , puisque en 8 bits c'est 1 fois.
    A+, pat

  7. #6
    Seb.26

    Re : init lcd en 4 bit

    Citation Envoyé par freepicbasic Voir le message
    Si l'envoie en 2 fois , alors le début est faux , puisque en 8 bits c'est 1 fois.
    J'avais pas vu ... tu as raison : si Lcd_Char() semble bien être en 4bits , la fonction SendCommand() semble être en mode 8bits ... donc ça peut pas marcher ... ou alors y'a un truc que j'ai zappé ...

    ... En même temps, Init_Lcd_4bit n'utilise pas SendCommand() ... donc ça devrait être OK ...

    PS:

    VarSend = 0x30;
    Lcd_Send(VarSend);
    VarSend = 0x30;
    Lcd_Send(VarSend);
    VarSend = 0x30;
    Lcd_Send(VarSend);

    est identique (et plus court) à

    Lcd_Send(0x30);
    Lcd_Send(0x30);
    Lcd_Send(0x30);

    ...

    Merci pour la datasheet, je vais aller à jeter un oeil ...

  8. #7
    Seb.26

    Re : init lcd en 4 bit

    Va voir le cycle d'init en page 47 ...

  9. #8
    sdow

    Re : init lcd en 4 bit

    sorry

    j'ai fait un modification dans init : il utilise SendCommand();

    je ne vois pas ou est mon prblème dans SendCommand();

  10. #9
    freepicbasic

    Re : init lcd en 4 bit

    mettre en,rs,r/W à 0
    attendre 14ms

    envoyer 0x30
    attendre 4.1ms

    clocker EN BSF,BCF
    attendre 100µs

    clocker EN BSF,BCF
    attendre 100µs

    envoyer 0x20 en mode 4 bits
    etc... en mode 4 bits
    A+, pat

  11. #10
    freepicbasic

    Re : init lcd en 4 bit

    List ASM de l'init 4bits
    Ici le poid fort du LCD est sur rb0-RB3
    0x30 => 0x3

    Code:
                                      00639 ;
    0146                              00640 _LCD_Init:
                                      00641 
    0146 1185       0005 03           00642         bcf     LCD_CNTL, _LCD_E     ; Clear all controll lines
    0147 1105       0005 02           00643         bcf     LCD_CNTL, _LCD_RS
    0148 1085       0005 01           00644         bcf     LCD_CNTL, _LCD_R_W
                                      00645 
    0149 216f       016f              00646         call    _Delay15000          ; Wait for 15ms for LCD to get powered up
                                      00647 
    014a 30f0       00f0              00648         movlw   0xf0
    014b 0586       0006 01           00649         andwf   LCD_DATA,F           ; Clear the lower nibble
    014c 3003       0003              00650         movlw   0x03                 ; Command for 4-bit interface high nibble
    014d 0486       0006 01           00651         iorwf   LCD_DATA,F           ; Send data to LCD
                                      00652 
    014e 1683       0003 05           00653         bsf     STATUS, RP0          ; Select Register page 1
    014f 30f0       00f0              00654         movlw   0x0F0
    0150 0506       0086 00           00655         andwf   LCD_DATA_TRIS,W
    ----                                    Error 86H Valeur >= 80H
                                      00656 
    0151 0086       0086              00657         movwf   LCD_DATA_TRIS        ; Set Port for output
    ----                                    Error 86H Valeur >= 80H
                                      00658 
    0152 1283       0003 05           00659         BCF     STATUS, RP0          ; Select Register page 0
                                      00660 
    0153 1585       0005 03           00661         bsf     LCD_CNTL, _LCD_E     ; Clock the initalize command to LCD module
    0154 1185       0005 03           00662         bcf     LCD_CNTL, _LCD_E
                                      00663 
    0155 216b       016b              00664         call    _Delay4100           ; Delay for at least 4.1ms before continuing
                                      00665 
    ASMPIC C:\PIC\PICBASIC\TESTLCD.ASM Released          1.04  Wed May 22 10:55:21 2002 Page 17
    
    LOC  OBJECT     CODE              LINE   SOURCE TEXT
    0156 1585       0005 03           00666         bsf     LCD_CNTL, _LCD_E     ; Clock the initalize command to LCD module
    0157 1185       0005 03           00667         bcf     LCD_CNTL, _LCD_E
                                      00668 
    0158 216d       016d              00669         call    _Delay100            ; delay for at least 100usec before continuing
                                      00670 
    0159 1585       0005 03           00671         bsf     LCD_CNTL, _LCD_E     ; Clock the initalize command to LCD module
    015a 1185       0005 03           00672         bcf     LCD_CNTL, _LCD_E
                                      00673 
    015b 212c       012c              00674         call    _Wait_Busy           ; From here on, the Busy Bit will be valid.
                                      00675 
    015c 30f0       00f0              00676         movlw   0xf0
    015d 0586       0006 01           00677         andwf   LCD_DATA,F           ; Clear the lower nibble
    015e 3002       0002              00678         movlw   0x02                 ; Command for 4-bit interface high nibble (Really an 8bit command but
                                      00679                                 ;   lower 4 bits are don't care at this point)
    015f 0486       0006 01           00680         iorwf   LCD_DATA,F           ; Send data to LCD                
                                      00681 
    0160 1585       0005 03           00682         bsf     LCD_CNTL, _LCD_E     ; Clock the initalize command to LCD module
    0161 1185       0005 03           00683         bcf     LCD_CNTL, _LCD_E
                                      00684 
    0162 3028       0028              00685         movlw   _FUNCTION_SET        ; Send the function set command 4-bit I/F, Font, Number of lines
    0163 2129       0129              00686         call    _Send_Cmd            ; Can now use the Send_Cmd routine since Busy Bit Valid and in 4bit mode.
    0164 3008       0008              00687         movlw   _DISP_OFF
    0165 2129       0129              00688         call    _Send_Cmd
    0166 300e       000e              00689         movlw   _DISP_ON_C
    0167 2129       0129              00690         call    _Send_Cmd
    0168 3006       0006              00691         movlw   _ENTRY_INC
    0169 2129       0129              00692         call    _Send_Cmd
    A+, pat

  12. #11
    sdow

    Re : init lcd en 4 bit

    salut


    mon init ne fonction toujours pas . je ne sias pas quoi faire . changer mon lcd ???? quel lcd choisir si je veux travailler en 4 bits

Discussions similaires

  1. [LCD] info sur LCD graphique LM6300 ?
    Par invite565767eb dans le forum Électronique
    Réponses: 2
    Dernier message: 02/12/2010, 22h01
  2. Compilateur CCS C - initialiser struct bit à bit ?
    Par branqueira dans le forum Électronique
    Réponses: 4
    Dernier message: 26/11/2007, 14h37
  3. [Brun] sortir menu init televiseur Thomson black diva
    Par invitea504fbf3 dans le forum Dépannage
    Réponses: 6
    Dernier message: 30/12/2006, 16h33
  4. Initialisation LCD Bit Enable ???
    Par invited72f7053 dans le forum Électronique
    Réponses: 3
    Dernier message: 20/07/2006, 10h17
  5. TVSony KV-32FC60Z chassis AE5: pb. init–Platine M
    Par invite58426cf9 dans le forum Dépannage
    Réponses: 13
    Dernier message: 10/11/2004, 17h45
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...