LCD 128x64 T6963C sur PIC16F876
Répondre à la discussion
Affichage des résultats 1 à 2 sur 2

LCD 128x64 T6963C sur PIC16F876



  1. #1
    invite58388f1a

    Unhappy LCD 128x64 T6963C sur PIC16F876


    ------

    Bonjour tout le monde !

    Je programme en C sur un PIC 16F876 et 16F84A.
    Depuis déjà bien longtemps, je voulais utiliser un ecran lcd que j'avais :
    DataVision, 128x64, backlight, T6963C, 2 x T6A39, T6A40.
    Je me suis debrouillé pour créer un -5V pour le contraste(qui marche bien).
    Je me suis fait une librairie, je l'ai relu mais je n'arrive a rien afficher sur cet ecran.

    Voici la librairie, que l'on peut par ailleurs retrouver sur le net en équivalence :

    #include "tempo.h"

    // Definition des ports A & B
    #define DIR_DATA TRISC
    #define DATA PORTC

    #define DIR_CTRL TRISB
    #define CTRL PORTB
    #define WRITE RB0
    #define READ RB1
    #define CHIP_ENABLED RB2
    #define DATA_or_CODE RB3
    #define RESET RB4
    #define BACKLIGHT RB5

    #define ON 1
    #define OFF 0

    // Definition des fonctions elementaires

    #define NOP asm("nop()");

    // [------------------- Pointer Set -------------------]
    #define Cursor_Pointer_Set PutCode(0x21);
    #define Offset_Register_Set PutCode(0x22);
    #define Address_Pointer_Set PutCode(0x24);

    // [------------------- Control Word -------------------]
    #define Text_Home_Address_Set PutCode(0x40);
    #define Text_Home_Address_High 0x20
    #define Text_Home_Address_Low 0x00

    #define Text_Area_Set PutCode(0x41);
    #define Text_Area_High 0x00
    #define Text_Area_Low 0x14

    #define Graphic_Home_Address_Set PutCode(0x42);
    #define Graphic_Home_Address_High 0x00
    #define Graphic_Home_Address_Low 0x00

    #define Graphic_Area_Set PutCode(0x43);
    #define Graphic_Area_High 0x00
    #define Graphic_Area_Low 0x14

    // [------------------- Mode Set -------------------]
    #define OR_Rom PutCode(0x80);
    #define OR_Ram PutCode(0x88);
    #define EXOR_Rom PutCode(0x81);
    #define EXOR_Ram PutCode(0x89);
    #define AND_Rom PutCode(0x83);
    #define AND_Ram PutCode(0x8B);
    #define Text_Rom PutCode(0x84);
    #define Text_Ram PutCode(0x8C);

    // [------------------- Lecture Ecran -------------------]
    #define Screen_Peeking PutCode(0xE0);
    #define Screen_Copy PutCode(0xE8);


    #define DataWriteIncrement PutCode(0xC0);
    #define DataReadIncrement PutCode(0xC1);
    #define DataWriteDecrement PutCode(0xC2);
    #define DataReadDecrement PutCode(0xC3);
    #define DataWriteUnchange PutCode(0xC4);
    #define DataReadUnchange PutCode(0xC5);

    // Definition des variables
    int BufferRead;


    int Immobile, SensDown, Read;

    void Short_Delay (void)
    {
    char count;
    count = 3;
    while (--count); /* delay */
    }

    void LcdReset(void)
    {
    RESET = 0;
    Tempo_ms(50);
    RESET = 1;
    }

    void GetData(char Val)
    {
    RA0=1;
    DIR_DATA = 0xFF;

    DATA_or_CODE = 0;

    WRITE = 1; READ = 0;
    CHIP_ENABLED = 0;

    Val = DATA;
    Tempo_ms(1);

    CHIP_ENABLED = 1;
    WRITE = 1; READ = 1;
    RA0=0;
    }

    int LcdBusy(void)
    {
    RA0=1;
    DIR_DATA = 0xFF;

    DATA_or_CODE = 1;

    WRITE = 1; READ = 0;
    CHIP_ENABLED = 0;

    BufferRead = DATA;
    Tempo_ms(1);

    CHIP_ENABLED = 1;
    WRITE = 1; READ = 1;
    RA0=0;
    return BufferRead;
    }

    void PutCode(unsigned char Val)
    {
    while((0x03 & LcdBusy()) != 0x03);
    RA2=1;
    DIR_DATA = 0x00;
    DATA = Val;

    DATA_or_CODE = 1;

    WRITE = 0; READ = 1;
    CHIP_ENABLED = 0;

    Tempo_ms(1);

    CHIP_ENABLED = 1;
    WRITE = 1; READ = 1;

    RA2=0;
    }

    void PutData(unsigned char Val)
    {
    while((0x03 & LcdBusy()) != 0x03);
    RA2=1;
    DIR_DATA = 0x00;
    DATA = Val;

    DATA_or_CODE = 0;

    WRITE = 0; READ = 1;
    CHIP_ENABLED = 0;

    Tempo_ms(1);

    CHIP_ENABLED = 1;
    WRITE = 1; READ = 1;

    RA2=0;
    }


    void MoveData(int Immo, int SDown, int ReadAct)
    {
    Immobile = Immo;
    SensDown = SDown;
    Read = ReadAct;
    }

    void DisplayModes(int Graphics, int Text, int Cursor, int CursorBlink)
    {
    PutCode(0x90 + Graphics * 8 + Text * 4 + Cursor * 2 + CursorBlink);
    }

    void CursorPattern(int NbrLigne)
    {
    PutCode(0xA0 + NbrLigne - 1);
    }

    void ChangeBit(int Set, int Position)
    {
    PutCode(0xF0 + Set * 8 + Position);
    }

    void SendCar(char Car)
    {
    char CarT6963C;
    CarT6963C = Car - 0x20;
    PutData(CarT6963C);
    DataWriteIncrement;
    }

    void SetAtHomeAddressMemory(void)
    {
    PutData(0x00);
    PutData(0x00);
    Address_Pointer_Set;
    }

    void SetAtHomeAddressTxt(void)
    {
    PutData(Text_Home_Address_Low) ;
    PutData(Text_Home_Address_High );
    Address_Pointer_Set;
    }

    void SetAtHomeAddressGraph(void)
    {
    PutData(Graphic_Home_Address_L ow);
    PutData(Graphic_Home_Address_H igh);
    Address_Pointer_Set;
    }

    void SetAtHomeCursorMemory(void)
    {
    PutData(0x00);
    PutData(0x00);
    Cursor_Pointer_Set;
    }

    void SetAtHomeCursorTxt(void)
    {
    PutData(Text_Home_Address_Low) ;
    PutData(Text_Home_Address_High );
    Cursor_Pointer_Set;
    }

    void SetAtHomeCursorGraph(void)
    {
    PutData(Graphic_Home_Address_L ow);
    PutData(Graphic_Home_Address_H igh);
    Cursor_Pointer_Set;
    }

    void ClearScreen(void)
    {
    int i;
    SetAtHomeAddressMemory();
    PutCode(0xB0);
    for(i = 0; i < 0x2000; i++) PutData(0xFF);
    PutCode(0xB2);
    SetAtHomeAddressMemory();
    }

    void LcdInit(void)
    {
    DIR_DATA = 0x00;
    DATA = 0;
    DIR_CTRL = 0x00;

    RESET = 1;
    WRITE = 1;
    READ = 1;
    CHIP_ENABLED = 1;
    BACKLIGHT = OFF;

    LcdReset();

    MoveData(0,0,0);

    AND_Rom;


    PutData(Graphic_Home_Address_L ow); // Graphic Home address
    PutData(Graphic_Home_Address_H igh);
    Graphic_Home_Address_Set; // 0x42

    PutData(Graphic_Area_Low); // Graphic Area set
    PutData(Graphic_Area_High);
    Graphic_Area_Set; // 0x43

    PutData(Text_Home_Address_Low) ; // Text Home address
    PutData(Text_Home_Address_High );
    Text_Home_Address_Set; // 0x40

    PutData(Text_Area_Low); // Text Area set
    PutData(Text_Area_High);
    Text_Area_Set; // 0x41


    PutData(Text_Home_Address_Low) ;
    PutData(Text_Home_Address_High );
    Address_Pointer_Set;

    PutData(Text_Home_Address_Low) ;
    PutData(Text_Home_Address_High );
    Cursor_Pointer_Set;


    }
    La librairie Tempo qui marche tres bien, verifié avec des leds et à l'oscilloscope :

    unsigned char Nbr;
    unsigned char Count;
    int FinTempo;


    void TempoInit(void);
    void Tempo_ms(int );
    void Tempo_s(int );
    static void interrupt Timer(void);


    void TempoInit(void)
    {
    GIE=1; PEIE=1;
    }


    void Tempo_ms(int Millisecondes) // Pas plus de 200ms
    {
    OPTION = 0b10000001; // Configuration tempo
    // 4 * 256 * 1 = 1.024ms
    FinTempo = 0;
    Nbr = 0;
    Count = Millisecondes;
    T0IE = 1;
    while(FinTempo!=1);
    }

    void Tempo_s(int Secondes)
    {
    OPTION = 0b10000101; // Configuration tempo
    // 4 * 256 * 1 = 1.024ms
    FinTempo = 0;
    Nbr = 0;
    Count = Secondes * 61;
    T0IE = 1;
    while(FinTempo!=1);
    }

    static void interrupt Timer(void)
    {
    if (T0IF)
    {
    Nbr++;
    if (Nbr>=Count)
    {
    FinTempo = 1;
    T0IE = 0;
    }
    T0IF=0;
    }
    }
    Le programme principale :

    #include "pic1687x.h"
    #include "LCD12864.h"

    void main(void)
    {
    TempoInit();
    LcdInit();

    ADCON1=6; // PORT A passe en mode Numérique
    OPTION=0b10000101; // Configure tmr0 pour 64µs par bit

    //[---------- Init Port ----------]


    ClearScreen();
    do
    {
    SendCar('A');
    }
    while(1);

    }
    Je remercie tout ceux qui voudront bien m'aider...
    Je commence vraiment à saturer...

    Merci

    nk36

    -----

  2. #2
    invite58388f1a

    Arrow Re : LCD 128x64 T6963C sur PIC16F876

    Bonjour !
    Bon j'ai trouvé mon probleme qui etait en fait niveau hard...
    PORTC => 45673210
    Au lieu de 76543210
    Du coup les commandes envoyer ne correspondait pas...
    Maintenant j'ai d'autres problemes...
    Il me met une erreur :
    Error [491] ; . can't find 0x2 words for psect "rdata_0" in segment "BANK0"
    Error [593] ; . can't find 0x3 words (0x3 withtotal) for psect "xtemp" in segment "BANK0"
    Error [593] ; . can't find 0x2 words (0x2 withtotal) for psect "code_ptr" in segment "BANK0"
    Error [593] ; . can't find 0x2 words (0x2 withtotal) for psect "intsave" in segment "BANK0"

    Je ne comprend pas comment il faut faire pour changer de "bank" en C
    Please help me !!!
    Je precise que je suis sur MPLab 7.62 avec PICC et que la cible est un PIC16F876.
    Merci tout le monde (ou personne lol)

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. Programme d'un pic16f876 sur 876A
    Par xarolium dans le forum Électronique
    Réponses: 2
    Dernier message: 23/09/2007, 13h10
  3. [lcd 128x64] Besoin d'informations
    Par invitef0cf02f0 dans le forum Électronique
    Réponses: 5
    Dernier message: 22/05/2007, 19h07
  4. Controle d'un T6963C en c/c++
    Par invitee17aeca5 dans le forum Électronique
    Réponses: 15
    Dernier message: 01/09/2006, 19h14
  5. Code C pour LCD T6963C et 16F877
    Par invitee45b5732 dans le forum Électronique
    Réponses: 0
    Dernier message: 18/04/2006, 19h03
Découvrez nos comparatifs produits sur l'informatique et les technologies.