Написать программу для отображения на экране ЖКИ тестовой строки «LCDTest», страница 2

    }

}

void SetDataBusValue( BYTE value)

{

    if(value & (1 << 0))//DB0

      FIO1SET |= BIT_1;

    else

      FIO1CLR |= BIT_1;

    if(value & (1 << 1))//DB1

      FIO1SET |= BIT_4;

    else

      FIO1CLR |= BIT_4;

    if(value & (1 << 2))//DB2

      FIO1SET |= BIT_8;

    else

      FIO1CLR |= BIT_8;

    if(value & (1 << 3))//DB3

      FIO1SET |= BIT_9;

    else

      FIO1CLR |= BIT_9;

    if(value & (1 << 4))//DB4

      FIO1SET |= BIT_10;

    else

      FIO1CLR |= BIT_10;

    if(value & (1 << 5))//DB5

      FIO1SET |= BIT_14;

    else

      FIO1CLR |= BIT_14;

    if(value & (1 << 6))//DB6

      FIO1SET |= BIT_15;

    else

      FIO1CLR |= BIT_15;

    if(value & (1 << 7))//DB7

      FIO1SET |= BIT_16;

    else

      FIO1CLR |= BIT_16;  

}

void WriteToIR(BYTE value) //Caienu a ?aaeno? eiiaia

{

    FIO0CLR |= BIT_3; //RS -> 0

    FIO0CLR |= BIT_2; //RW -> 0

    SetDataBusDirection(TRUE);

    SetDataBusValue(value);

    Delay(1);

    FIO1SET |= BIT_0; //E  -> 1

    Delay(1);

    FIO1CLR |= BIT_0; //E  -> 0

    Delay(1);

}

void WriteToDR(BYTE value) //Caienu a ?aaeno? aaiiuo

{

    FIO0SET |= BIT_3; //RS -> 1

    FIO0CLR |= BIT_2; //RW -> 0

    SetDataBusDirection(TRUE);

    SetDataBusValue(value);

    Delay(1);

    FIO1SET |= BIT_0; //E  -> 1

    Delay(1);

    FIO1CLR |= BIT_0; //E  -> 0

    Delay(50);

}

void InitWH1602D( void )

{

    FIO0DIR |= BIT_3; //Iai?aaeaiea ?ac?yaa ii?oa aey RS

    FIO0DIR |= BIT_2; //Iai?aaeaiea ?ac?yaa ii?oa aey RW

    FIO1DIR |= BIT_0; //Iai?aaeaiea ?ac?yaa ii?oa aey E

    FIO0CLR |= BIT_3 | BIT_2; //Ia?aeuiay onoaiiaea RS, RW

    FIO1CLR |= BIT_0;//Ia?aeuiay onoaiiaea E

    Delay(50000); //Caaa?ea ia 50 in iinea aee??aiey ieoaiey

    WriteToIR(0x3C); //Ia?aiao?u eiaeeaoi?a

    Delay(50);

    WriteToIR(0x0C);//Aee??aiea aenieay

    Delay(50);

    WriteToIR(0x01); //I?enoea aenieay

    Delay(2000);

    WriteToIR(0x06);//?a?ei aaoiiaoe?aneiai ia?aiauaiey eo?ni?a

    Delay(50);

}

void LCD_Test()

{

            WriteToIR(0x01); //I?enoea aenieay

            Delay(2000);

            WriteToDR('L'); //Auaia ia ?EE oanoiaie no?iee

            WriteToDR('C');

            WriteToDR('D');

            WriteToDR(' ');

            WriteToDR('T');

            WriteToDR('E');

            WriteToDR('S');

            WriteToDR('T');

}

void String2LCD( char *pString, int Length )

{

            __disable_interrupt();

            WriteToIR(0x01);

            Delay(2000);

            while( Length-- )

            {

                        WriteToDR((BYTE)(*pString++));

            }

            __enable_interrupt();

}

 int main(void)

{  

  SCS |= 0x20;           // ?ac?aoeou aaia?aoi? n eaa?oaaui ?aciiaoi?ii 12IAo

  while( !(SCS & 0x40) ); // Iiai?aaou noaaeeecaoee ?anoiou aaia?aoi?a

  CLKSRCSEL = 0x01;       //Aua?aou aaia?aoi? n eaa?oaaui ?aciiaoi?ii 12IAo a ea?anoaa iniiaiiai

  PCLKSEL0 = 0x0004; // 0000 0100 - aaie?iue aea eiiaeiaoee 01 aey ?ac?yaia 3:2

  // Iano?ieou ii?o

  SCS |= 0x01;      // ?ac?aoeou auno?ue aaia/auaia