Changes between Version 9 and Version 10 of SujetTP3-2017


Ignore:
Timestamp:
Feb 10, 2017, 8:37:35 AM (8 years ago)
Author:
franck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SujetTP3-2017

    v9 v10  
    5757
    5858Pour contrôler l'afficheur nous devons répondre aux questions suivantes:
     59Les réponses à ces questions se trouve dans la documentation de l'afficheur.
    5960* Comment faut-il configurer les GPIOs pour les différents signaux de l'afficheur LCD ?
    6061* Comment écrire des valeurs vers le LCD ?
     
    6364* Comment envoyer des commandes telles que : l'effacement de l'écran, le déplacement du curseur, etc. ?
    6465
     66Page 11 de la documentation : [[http://www.newhavendisplay.com/specs/NHD-0420DZ-FL-YBW.pdf | Datasheet du LCD de la plateforme]]
     67{{{#!c
     684-bit Initialization:
     69/**********************************************************/
     70void command(char i)
     71{
     72  P1 = i;                       //put data on output Port
     73  D_I =0;                       //D/I=LOW : send instruction
     74  R_W =0;                       //R/W=LOW : Write       
     75  Nybble();                     //Send lower 4 bits
     76  i = i<<4;                     //Shift over by 4 bits
     77  P1 = i;                       //put data on output Port
     78  Nybble();                     //Send upper 4 bits
     79}
     80/**********************************************************/
     81void write(char i)
     82{
     83  P1 = i;                       //put data on output Port
     84  D_I =1;                       //D/I=HIGH : send data
     85  R_W =0;                       //R/W=LOW : Write   
     86  Nybble();                     //Clock lower 4 bits
     87  i = i<<4;                     //Shift over by 4 bits
     88  P1 = i;                       //put data on output Port
     89  Nybble();                     //Clock upper 4 bits
     90}
     91/**********************************************************/
     92void Nybble()
     93{
     94  E = 1;
     95  Delay(1);                     //enable pulse width  >= 300ns
     96  E = 0;                        //Clock enable: falling edge
     97}
     98/**********************************************************/
     99void init()
     100{
     101  P1 = 0;
     102  P3 = 0;
     103  Delay(100);                   //Wait >40 msec after power is applied
     104  P1 = 0x30;                    //put 0x30 on the output port
     105  Delay(30);                    //must wait 5ms, busy flag not available
     106  Nybble();                     //command 0x30 = Wake up 
     107  Delay(10);                    //must wait 160us, busy flag not available
     108  Nybble();                     //command 0x30 = Wake up #2
     109  Delay(10);                    //must wait 160us, busy flag not available
     110  Nybble();                     //command 0x30 = Wake up #3
     111  Delay(10);                    //can check busy flag now instead of delay
     112  P1= 0x20;                     //put 0x20 on the output port
     113  Nybble();                     //Function set: 4-bit interface
     114  command(0x28);                //Function set: 4-bit/2-line
     115  command(0x10);                //Set cursor
     116  command(0x0F);                //Display ON; Blinking cursor
     117  command(0x06);                //Entry Mode set
     118}
     119/**********************************************************/
     120}}}
    65121== 2. Fonctionnement de l'écran et fonctions de base ==
    66122