Répondre à la discussion
Affichage des résultats 1 à 18 sur 18

Lcd 2*16 pic c18



  1. #1
    cyrildele

    Lcd 2*16 pic c18


    ------

    Bonjour à tous,

    J'ai un petit souci pour afficher du texte sur un afficheur LCD 2x16.
    datasheet: http://www.farnell.com/datasheets/1485447.pdf

    L'erreur doit etre au niveau du programme:


    Code:
    #include <p18f2525.h>
    #include "main.h"
    #include <sw_uart.h>
    #include <stdlib.h>
    #include <string.h>
    #include <timers.h> // Timer library functions
    #include <delays.h>
    #include <math.h>
    #include <stdio.h>
    #include <portb.h>
    
    
    #pragma code
    //---------------------------------------------------------------------
    //interruption haute
    //---------------------------------------------------------------------
    #pragma interrupt High_isr
    
     void High_isr(void)
     {
        unsigned char a;
        
        if (PIR1bits.RCIF == 1) //interruption voie série 1 réception
        {
            //ceci raz le flag
            // PIR1bits.RCIF = 0;
            a = RCREG;
    
            // Clear the overrun error condition
            if (RCSTAbits.FERR || RCSTAbits.OERR)
            {
                RCSTAbits.CREN = 0;
                RCSTAbits.CREN = 1;
    
            }
            if (a != 0xa)
            {
                if (a == 0x0d)
                {
                    *p_ecrit_buffe = 0;
                    p_ecrit_buffe = buffe;
                    flag.b_SERIE_RX = 1;
                }
                else *p_ecrit_buffe++ = a;
            }
        }
    
    }
    //---------------------------------------------------------------------
    //interruption basse
    //---------------------------------------------------------------------
    #pragma interrupt Low_isr
    
    void Low_isr(void)  {
    }
    
    #pragma code
    
    
    
    // LCD
    #define RS PORTBbits.RB2
    #define EN PORTBbits.RB0
    #define LCD_OUT PORTC
    
    // delay function
    void _delay_us (unsigned char us)
        {
    	while(us--)
            {
    		Nop();
    		Nop();
    	}
    }
    
    
    void _delay_ms(unsigned char  ms)
    {
    	unsigned char	i, j;
    	while(ms--){
            for (i = 0; i < 20; i++)
            for (j = 0; j < 100; j++)
            Nop();
            };
    }
    
    // void LCD_STROBE
    void LCD_STROBE()
    {
        EN=1;
        EN=0;
    }
    
    void LCD_DATA(unsigned char c)
    {
        unsigned char temp, h_nibble, l_nibble;
        RS=1;
        _delay_us(50);           // delay 50us
        temp=LCD_OUT&0xF0;
        h_nibble=(c>>4)&0x0F;
        l_nibble=c&0x0F;
        LCD_OUT = temp|h_nibble;    /// send 4 high bit
        LCD_STROBE();
        LCD_OUT=temp|l_nibble;         // send 4 low bit
        LCD_STROBE();
        _delay_us(50);
    }
    
    void LCD_CMD(unsigned char c)
    {
        unsigned char temp, h_nibble, l_nibble;
        RS = 0;
        _delay_us(50);
        temp=LCD_OUT&0xF0;
        h_nibble=(c>>4)&0x0F;
        l_nibble=c&0x0F;
        LCD_OUT = temp|h_nibble;    //// send 4 high bit
      //  LCD_STROBE();
      //  LCD_OUT=temp|l_nibble;         // send 4 low bit
       LCD_STROBE();
        _delay_us(50);
    }
    
    void clear(void) // Clear dislay
    {
        LCD_CMD(0x10);
        _delay_ms(2);
    }
    
    void LCD_INIT()
    {
        TRISC = 0;
        TRISB = 0;
        RS = 0;
    
        _delay_ms(100);
        LCD_CMD(0x30);
        _delay_ms(10);
        LCD_CMD(0x30);
        _delay_ms(1);
        LCD_CMD(0x30);
    
        LCD_CMD(0x20);
    
        LCD_CMD(0x20);// Function set (4 bit mode)  0010 1000
        LCD_CMD(0x80);
    
        LCD_CMD(0x00); // Display OFF
        LCD_CMD(0xF0);
    
        LCD_CMD(0x00);// Display clear
        LCD_CMD(0x10);
    
        LCD_CMD(0x00); //Entry mode set
        LCD_CMD(0x40);
    }
    
    void string(const char *q)
    {
        while(*q)
        {
            LCD_DATA(*q++);
        }
    }
    //---------------------------------------------------------------------
    //MAIN
    //---------------------------------------------------------------------
    void main(void)
    {
        RS = 0;  
        LCD_INIT();
    
        string("TEST");
    }
    Merci d'avance pour votre aide.

    -----

  2. Publicité
  3. #2
    gabuzo

    Re : Lcd 2*16 pic c18

    Citation Envoyé par cyrildele Voir le message


    L'erreur doit etre au niveau du programme:

    Erreur de copier/coller...
    Je suis Charlie

  4. #3
    cyrildele

    Re : Lcd 2*16 pic c18

    ou pas...


    Bien sur je me suis inspiré de code existant mais pas de ctrl+c ctrl+v.

    Une meilleur proposition pour m'aider?

    Merci.

  5. #4
    paulfjujo

    Re : Lcd 2*16 pic c18

    bonjour,


    pourquoi n'envoyer qu'un quartet pour la commande ?
    Schema ?
    Ou sont connecter les 4 bits du port C sur le LCD
    verifier si il n'y a pas une config analogique par defaut sur le PORTC et PORTB


    Code:
    void LCD_CMD(unsigned char c)
    {
        unsigned char temp, h_nibble, l_nibble;
        RS = 0;
        _delay_us(50);
        temp=LCD_OUT&0xF0;
        h_nibble=(c>>4)&0x0F;
        l_nibble=c&0x0F;
        LCD_OUT = temp|h_nibble;    //// send 4 high bit
        LCD_STROBE();
        LCD_OUT=temp|l_nibble;         // send 4 low bit
       LCD_STROBE();
        _delay_us(50);
    }

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

    Re : Lcd 2*16 pic c18

    Je reposte mon code un peu modifié:

    Code:
    #include <p18f2525.h>
    #include "main.h"
    #include <sw_uart.h>
    #include <stdlib.h>
    #include <string.h>
    #include <timers.h> // Timer library functions
    #include <delays.h>
    #include <math.h>
    #include <stdio.h>
    #include <portb.h>
    
    
    #pragma code
    //---------------------------------------------------------------------
    //interruption haute
    //---------------------------------------------------------------------
    #pragma interrupt High_isr
    
     void High_isr(void)
     {
        unsigned char a;
        
        if (PIR1bits.RCIF == 1) //interruption voie série 1 réception
        {
            //ceci raz le flag
            // PIR1bits.RCIF = 0;
            a = RCREG;
    
            // Clear the overrun error condition
            if (RCSTAbits.FERR || RCSTAbits.OERR)
            {
                RCSTAbits.CREN = 0;
                RCSTAbits.CREN = 1;
    
            }
            if (a != 0xa)
            {
                if (a == 0x0d)
                {
                    *p_ecrit_buffe = 0;
                    p_ecrit_buffe = buffe;
                    flag.b_SERIE_RX = 1;
                }
                else *p_ecrit_buffe++ = a;
            }
        }
    
    }
    //---------------------------------------------------------------------
    //interruption basse
    //---------------------------------------------------------------------
    #pragma interrupt Low_isr
    
    void Low_isr(void)  {
    }
    
    #pragma code
    
    
    
    // LCD
    #define RS PORTBbits.RB2
    #define EN PORTBbits.RB0
    #define LCD_OUT PORTC
    
    // delay function
    void _delay_us (unsigned char us)
        {
    	while(us--)
            {
    		Nop();
    		Nop();
    	}
    }
    
    
    void _delay_ms(unsigned char  ms)
    {
    	unsigned char	i, j;
    	while(ms--){
            for (i = 0; i < 20; i++)
            for (j = 0; j < 100; j++)
            Nop();
            };
    }
    
    // void LCD_STROBE
    void LCD_STROBE()
    {
        EN=1;
        EN=0;
    }
    
    void LCD_DATA(unsigned char c)
    {
        unsigned char temp, h_nibble, l_nibble;
        RS=1;
        _delay_us(50);           // delay 50us
        temp=LCD_OUT&0xF0;
        h_nibble=(c>>4)&0x0F;
        l_nibble=c&0x0F;
        LCD_OUT = temp|h_nibble;    /// send 4 high bit
        LCD_STROBE();
        LCD_OUT=temp|l_nibble;         // send 4 low bit
        LCD_STROBE();
        _delay_us(50);
    }
    
    void LCD_CMD(unsigned char c)
    {
        unsigned char temp, h_nibble, l_nibble;
        RS = 0;
        _delay_us(50);
        temp=LCD_OUT&0xF0;
        h_nibble=(c>>4)&0x0F;
        l_nibble=c&0x0F;
        LCD_OUT = temp|h_nibble;    //// send 4 high bit
        LCD_STROBE();
        LCD_OUT=temp|l_nibble;         // send 4 low bit
       LCD_STROBE();
        _delay_us(50);
    }
    
    void clear(void) // Clear dislay
    {
        LCD_CMD(0x10);
        _delay_ms(2);
    }
    
    void LCD_INIT()
    {
        TRISC = 0;
        TRISB = 0;
        RS = 0;
    
        _delay_ms(100);
        LCD_CMD(0x30);
        _delay_ms(10);
        LCD_CMD(0x30);
        _delay_ms(1);
        LCD_CMD(0x30);
    
        LCD_CMD(0x20);
    
        LCD_CMD(0x28);// Function set (4 bit mode)  0010 1000
    
        LCD_CMD(0x0F); // Display OFF
    
        LCD_CMD(0x01);// Display clear
    
        LCD_CMD(0x04); //Entry mode set
    }
    
    void string(const char *q)
    {
        while(*q)
        {
            LCD_DATA(*q++);
        }
    }
    
    //---------------------------------------------------------------------
    //MAIN
    //---------------------------------------------------------------------
    void main(void)
    {
        LCD_INIT();
        
        string("3X");
    }
    J'arrive à déplacer le curseur sur l'écran mais je n'arrive pas à écrire...

    Merci.

  8. #6
    cyrildele

    Re : Lcd 2*16 pic c18

    DB4...DB7 -> RC0...RC3
    En -> RB0
    RS -> RB2

    Ca semble bon pour l'initialisation, il ne doit pas y avoir d'erreur au niveau hardware.

    Le problème doit etre dans la routine d'écriture de caractère... j'oublie certainement qq chose...

  9. Publicité
  10. #7
    paulfjujo

    Re : Lcd 2*16 pic c18

    Code:
    void main(void)
    {
        LCD_INIT();
        string("3X");
       while(1);
    }

  11. #8
    cyrildele

    Re : Lcd 2*16 pic c18

    J'ai essayé mais ca ne marche pas.

    Après "init" j'ai le curseur au 1er caractère qui clignote.

    et après "string("3X")" j'ai les caractères de la 1ere ligne noir et la seconde ligne les 3 lignes du haut noir sur les 16 caractères...

    Merci pour ton aide.

  12. #9
    cyrildele

    Re : Lcd 2*16 pic c18

    Voici mon code un peu simplifié mais il ne fonctionne toujours pas :s

    #include <p18f2525.h>
    #include "main.h"
    #include <sw_uart.h>
    #include <stdlib.h>
    #include <string.h>
    #include <timers.h> // Timer library functions
    #include <delays.h>
    #include <math.h>
    #include <stdio.h>
    #include <portb.h>

    /*
    #pragma code
    //---------------------------------------------------------------------
    //interruption haute
    //---------------------------------------------------------------------
    #pragma interrupt High_isr

    void High_isr(void)
    {
    unsigned char a;

    if (PIR1bits.RCIF == 1) //interruption voie série 1 réception
    {
    //ceci raz le flag
    // PIR1bits.RCIF = 0;
    a = RCREG;

    // Clear the overrun error condition
    if (RCSTAbits.FERR || RCSTAbits.OERR)
    {
    RCSTAbits.CREN = 0;
    RCSTAbits.CREN = 1;

    }
    if (a != 0xa)
    {
    if (a == 0x0d)
    {
    *p_ecrit_buffe = 0;
    p_ecrit_buffe = buffe;
    flag.b_SERIE_RX = 1;
    }
    else *p_ecrit_buffe++ = a;
    }
    }

    }
    //---------------------------------------------------------------------
    //interruption basse
    //---------------------------------------------------------------------
    #pragma interrupt Low_isr

    void Low_isr(void) {
    }

    #pragma code

    */

    // LCD
    #define RS PORTBbits.RB2
    #define EN PORTBbits.RB0
    #define LCD_OUT PORTC

    // delay function
    void _delay_us (unsigned char us)
    {
    while(us--)
    {
    Nop();
    Nop();
    }
    }

    void _delay_ms(unsigned char ms)
    {
    unsigned char i, j;
    while(ms--)
    {
    for (i = 0; i < 20; i++)
    for (j = 0; j < 100; j++)
    Nop();
    };
    }

    // void LCD_STROBE
    void LCD_STROBE()
    {
    EN=1;
    _delay_us(5);
    EN=0;
    }

    void LCD_DATA(unsigned char c)
    {
    RS = 1;
    _delay_us(50);
    PORTC = (c >> 4);
    LCD_STROBE();
    PORTC = (c);
    LCD_STROBE();
    }

    void LCD_CMD(unsigned char c)
    {
    RS = 0;
    _delay_us(50);
    PORTC = (c >> 4);
    LCD_STROBE();
    PORTC = (c);
    LCD_STROBE();
    }

    void clear(void) // Clear dislay
    {
    LCD_CMD(0x01);
    _delay_ms(2);
    }

    void LCD_INIT()
    {
    TRISC = 0;
    TRISB = 0;
    PORTBbits.RB1 = 0;
    RS = 0;

    _delay_ms(100);
    LCD_CMD(0x30);
    _delay_ms(10);
    LCD_CMD(0x30);
    _delay_ms(1);
    LCD_CMD(0x30);

    LCD_CMD(0x20);

    LCD_CMD(0x28);// Function set (4 bit mode) 0010 1000

    LCD_CMD(0x0C); // Display OFF

    LCD_CMD(0x01);// Display clear

    LCD_CMD(0x06); //Entry mode set
    }

    void string(const char *q)
    {
    while(*q)
    {
    LCD_DATA(*q++);
    }
    }

    //---------------------------------------------------------------------
    //MAIN
    //---------------------------------------------------------------------
    void main(void)
    {
    PORTBbits.RB1 = 0;

    LCD_INIT();

    LCD_DATA('X');

    while(1);

    }

  13. #10
    _asm_

    Re : Lcd 2*16 pic c18

    Salut
    Essaye d'ajouter LCD_CMD(0x80); à la fin de l'init.

  14. #11
    cyrildele

    Re : Lcd 2*16 pic c18

    POur mettre adresse DDRAM à 0?

    J'ai essayé ca ne fonctionne pas :s

  15. #12
    cyrildele

    Re : Lcd 2*16 pic c18

    une petite idée ça fait des heures que je bloque dessus?

    je ne comprends pas pourquoi ça n'écrit pas sur le lcd...

    merci.

  16. Publicité
  17. #13
    _asm_

    Re : Lcd 2*16 pic c18

    Peux-mettre un schéma et l'initialisation du pic ?

  18. #14
    cyrildele

    Re : Lcd 2*16 pic c18

    Nom : Sans titre.png
Affichages : 16
Taille : 29,8 Ko

    Bonjour,

    voici la config:

    Code:
    /* 
     * File:   main.h
     * Author: Cyril
     *
     * Created on 28 avril 2014, 11:27
     */
    
    #ifndef MAIN_H
    #define	MAIN_H
    
    #ifdef	__cplusplus
    extern "C" {
    #endif
    
    
    
    
    #ifdef	__cplusplus
    }
    #endif
    
    #endif	/* MAIN_H */
    
    
    char *p_ecrit_buffe;
    char buffe[60];
    
    struct
    {
        unsigned 	b_SERIE_RX:1;
    }flag;
    
    
    
    // CONFIG1H
    #pragma config OSC = INTIO7     // Oscillator Selection bits (Internal oscillator block, CLKOUT function on RA6, port function on RA7)
    #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
    #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
    
    // CONFIG2L
    #pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
    #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
    #pragma config BORV = 3         // Brown Out Reset Voltage bits (Minimum setting)
    
    // CONFIG2H
    #pragma config WDT = OFF         // Watchdog Timer Enable bit (WDT enabled)
    #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
    
    // CONFIG3H
    #pragma config CCP2MX = PORTC   // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
    #pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
    #pragma config LPT1OSC = OFF    // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation)
    #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
    
    // CONFIG4L
    #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
    #pragma config LVP = OFF         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
    #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
    
    // CONFIG5L
    #pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-003FFFh) not code-protected)
    #pragma config CP1 = OFF        // Code Protection bit (Block 1 (004000-007FFFh) not code-protected)
    #pragma config CP2 = OFF        // Code Protection bit (Block 2 (008000-00BFFFh) not code-protected)
    
    // CONFIG5H
    #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
    #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
    
    // CONFIG6L
    #pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-003FFFh) not write-protected)
    #pragma config WRT1 = OFF       // Write Protection bit (Block 1 (004000-007FFFh) not write-protected)
    #pragma config WRT2 = OFF       // Write Protection bit (Block 2 (008000-00BFFFh) not write-protected)
    
    // CONFIG6H
    #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
    #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
    #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
    
    // CONFIG7L
    #pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
    #pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
    #pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
    
    // CONFIG7H
    #pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)



    mon programme:


    Code:
    #include <p18f2525.h>
    #include "main.h"
    #include <sw_uart.h>
    #include <stdlib.h>
    #include <string.h>
    #include <timers.h> // Timer library functions
    #include <delays.h>
    #include <math.h>
    #include <stdio.h>
    #include <portb.h>
    
    /*
    #pragma code
    //---------------------------------------------------------------------
    //interruption haute
    //---------------------------------------------------------------------
    #pragma interrupt High_isr
    
     void High_isr(void)
     {
        unsigned char a;
        
        if (PIR1bits.RCIF == 1) //interruption voie série 1 réception
        {
            //ceci raz le flag
            // PIR1bits.RCIF = 0;
            a = RCREG;
    
            // Clear the overrun error condition
            if (RCSTAbits.FERR || RCSTAbits.OERR)
            {
                RCSTAbits.CREN = 0;
                RCSTAbits.CREN = 1;
    
            }
            if (a != 0xa)
            {
                if (a == 0x0d)
                {
                    *p_ecrit_buffe = 0;
                    p_ecrit_buffe = buffe;
                    flag.b_SERIE_RX = 1;
                }
                else *p_ecrit_buffe++ = a;
            }
        }
    
    }
    //---------------------------------------------------------------------
    //interruption basse
    //---------------------------------------------------------------------
    #pragma interrupt Low_isr
    
    void Low_isr(void)  {
    }
    
    #pragma code
    
    */
    
    // LCD
    #define RS PORTBbits.RB2
    #define EN PORTBbits.RB0
    #define LCD_OUT PORTC
    
    // delay function
    void _delay_us (unsigned char us)
    {
        while(us--)
        {
            Nop();
            Nop();
        }
    }
    
    void _delay_ms(unsigned char  ms)
    {
        unsigned char i, j;
        while(ms--)
        {
        for (i = 0; i < 20; i++)
        for (j = 0; j < 100; j++)
        Nop();
        };
    }
    
    // void LCD_STROBE
    void LCD_STROBE()
    {
        EN = 1;
        _delay_us(20);
        EN = 0;
    }
    
    void LCD_DATA(unsigned char c)
    {
        RS = 1;
        _delay_us(50);
        PORTC = (c >> 4);
        LCD_STROBE();
        PORTC = (c);
        LCD_STROBE();
    }
    
    void LCD_CMD(unsigned char c)
    {
        RS = 0;
        _delay_us(50);
        PORTC = (c >> 4);
        LCD_STROBE();
        PORTC = (c);
        LCD_STROBE();
    }
    
    void clear(void) // Clear dislay
    {
        LCD_CMD(0x01);
        _delay_ms(2);
    }
    
    void LCD_INIT()
    {
        TRISCbits.RC0 = 0;
        TRISCbits.RC1 = 0;
        TRISCbits.RC2 = 0;
        TRISCbits.RC3 = 0;
        TRISBbits.RB0 = 0;
        TRISBbits.RB1 = 0;
        TRISBbits.RB2 = 0;
        PORTBbits.RB1 = 0;
        RS = 0;
        _delay_ms(50);
        LCD_CMD(0x30);
        _delay_ms(5);
        LCD_CMD(0x30);
        _delay_ms(1);
        LCD_CMD(0x30);
        _delay_ms(1);
    
        LCD_CMD(0x20);
        _delay_ms(1);
    
        LCD_CMD(0x28);// Function set (4 bit mode)  0010 1000
        _delay_ms(1);
    
        LCD_CMD(0x0C); // Display OFF
        _delay_ms(1);
    
        LCD_CMD(0x01);// Display clear
        _delay_ms(1);
    
        LCD_CMD(0x06); //Entry mode set
        _delay_ms(1);
    
        LCD_CMD(0x0F); // Display ON
        _delay_ms(1);
    
    }
    
    void string(const char *q)
    {
        while(*q)
        {   
            LCD_DATA(*q++);
        }
    }
    
    //---------------------------------------------------------------------
    //MAIN
    //---------------------------------------------------------------------
    void main(void)
    {
        PORTBbits.RB1 = 0;
    
        LCD_INIT();
    
    //    LCD_CMD(0x80);
    
        LCD_DATA('Y');
    
        while(1);
    
    }
    Merci.

  19. #15
    cyrildele

    Re : Lcd 2*16 pic c18

    Je pense avoir trouvé le problème, mais pas la solution:

    problème:

    RS passe à l'état bas quand EN passe à l'état haut (vu sur oscilloscope)


    void LCD_STROBE()
    {
    EN = 1; <-- RS passe à 0 ici pourquoi?
    _delay_us(20);
    EN = 0;
    }


    Alors que je l'ai mis à 1 avant:

    void LCD_DATA(unsigned char c)
    {
    RS = 1; <-- état haut de RS
    _delay_us(50);
    d = (c >> 4);
    PORTC = d;
    LCD_STROBE();

  20. #16
    paulfjujo

    Re : Lcd 2*16 pic c18

    bonjour


    Code:
    #define RS PORTBbits.RB2
    #define EN PORTBbits.RB0
    comme ce sont des sorties essaie avec LAT

    Code:
    #define RS LATBbits.LATB2
    #define EN LATBbits.LATB0

  21. #17
    cyrildele

    Re : Lcd 2*16 pic c18

    Super ca fonctionne! merci!!

    LCD_DATA('Y'); <-- cette fonction écrit bien
    string("OK"); <-- mais celle ci ne fonctionne pas...

    void string(const char *q)
    {
    while(*q)
    {
    LCD_DATA(*q++);
    }
    }

  22. #18
    paulfjujo

    Re : Lcd 2*16 pic c18

    y a pas de raison.... c'est OK avec un envoi sur UART1_Write-*q++);
    et peut etre une petite tempo entre chaque caractere?

    si ce n'est qu'il faut aussi LAT au lieu de PORT ICI
    Code:
    void LCD_DATA(unsigned char c)
    {
        RS = 1;
        _delay_us(50);
        LATC = (c >> 4);
        LCD_STROBE();
        LATC = (c);
        LCD_STROBE();
    }
    
    
    void string(const char *q)
    {
    while(*q)
    { 
    LCD_DATA(*q++);
    Delay_ms(10); // utile ?
    }
    }

  23. Publicité
Découvrez nos comparatifs produits sur l'informatique et les technologies.