Lcd sorunu...

Başlatan Yücel BOZDEMİR, 15 Nisan 2015, 22:57:41

Yücel BOZDEMİR

Lcd'de istediğim karakterleri yazdıramıyorum.Ancak bir röle için uygulamayı derleyip çalıştırdığımda sorunsuz istediğim gibi çalışıyor ancak 5'ini devreye aldığımda isis similasyonunda istediğim gibi çalışmadığını görüyorum sebebi ne olabilir?


// LCD module connections
 sbit LCD_RS at RB0_bit;
 sbit LCD_EN at RB1_bit;
 sbit LCD_D4 at RB2_bit;
 sbit LCD_D5 at RB3_bit;
 sbit LCD_D6 at RB4_bit;
 sbit LCD_D7 at RB5_bit;
 sbit LCD_RS_Direction at TRISB0_bit;
 sbit LCD_EN_Direction at TRISB1_bit;
 sbit LCD_D4_Direction at TRISB2_bit;
 sbit LCD_D5_Direction at TRISB3_bit;
 sbit LCD_D6_Direction at TRISB4_bit;
 sbit LCD_D7_Direction at TRISB5_bit;
 // End LCD module connections
 // Software I2C connections
 sbit Soft_I2C_Scl           at RC4_bit;
 sbit Soft_I2C_Sda           at RC3_bit;
 sbit Soft_I2C_Scl_Direction at TRISC4_bit;
 sbit Soft_I2C_Sda_Direction at TRISC3_bit;
 // End Software I2C connections
 unsigned char  saniye, saniye10, dakika, dakika10,
               saat, saat10, tarih, tarih10, ay, ay10,
               yil, yil10, gun ,ayarmenu=1;
 char txt2[]="00",txt1[]="00",txt3[]="BASLANGIC SAAT:",txt4[]="BASLANGIC DAKIKA:",
      txt5[]="BITIS SAAT:",txt6[]="BITIS DAKIKA:",txt7[]="00",txt8[]="00";

 signed short r1dakka=0,r2dakka=0,r3dakka=0,r4dakka=0,r5dakka=0,
              r1saat=0,r2saat=0,r3saat=0,r4saat=0,r5saat=0,ayar=0,
              rb1dakka=0,rb2dakka=0,rb3dakka=0,rb4dakka=0,rb5dakka=0,
              rb1saat=0,rb2saat=0,rb3saat=0,rb4saat=0,rb5saat=0;

 #define arttir PORTA.RA0
 #define set PORTA.RA1
 #define azalt PORTA.RA2
  void bas1()
    {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
     case 0:txt1[1]=(r1saat%10)+48;
            txt1[0]=(r1saat/10)+48;
            Lcd_Out(1,1,txt3);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);

            if (arttir==0){delay_ms(200);r1saat++;if (r1saat>=24){r1saat=0;}}
            else if (azalt==0){delay_ms(200);r1saat--;if (r1saat<=-1){r1saat=23;}}
      break;

     case 1:
            txt2[1]=(r1dakka%10)+48;
            txt2[0]=(r1dakka/10)+48;
            Lcd_Out(1,1,txt4);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
             if (arttir==0){delay_ms(200);r1dakka++;if (r1dakka>=60){r1dakka=0;}}
             else if (azalt==0){delay_ms(200);r1dakka--;if (r1dakka<=-1){r1dakka=59;}}
      break;

   }}

   
   }
  void bas2()
    {
    while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
     case 0:
            txt1[1]=(r2saat%10)+48;
            txt1[0]=(r2saat/10)+48;
            Lcd_Out(1,1,txt3);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
            
            if (arttir==0){delay_ms(200);r2saat++;if (r2saat>=24){r2saat=0;}}
            else if (azalt==0){delay_ms(200);r2saat--;if (r2saat<=-1){r2saat=23;}}
      break;

     case 1:
            txt2[1]=(r2dakka%10)+48;
            txt2[0]=(r2dakka/10)+48;
            Lcd_Out(1,1,txt4);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
             if (arttir==0){delay_ms(200);r2dakka++;if (r2dakka>=60){r2dakka=0;}}
             else if (azalt==0){delay_ms(200);r2dakka--;if (r2dakka<=-1){r2dakka=59;}}
      break;

   }}

   }
 void bas3()
    {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
     case 0:
            txt1[1]=(r3saat%10)+48;
            txt1[0]=(r3saat/10)+48;
            Lcd_Out(1,1,txt3);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
            if (arttir==0){delay_ms(200);r3saat++;if (r3saat>=24){r3saat=0;}}
            else if (azalt==0){delay_ms(200);r3saat--;if (r3saat<=-1){r3saat=23;}}
      break;

     case 1:
            txt2[1]=(r3dakka%10)+48;
            txt2[0]=(r3dakka/10)+48;
            Lcd_Out(1,1,txt4);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
             if (arttir==0){delay_ms(200);r3dakka++;if (r3dakka>=60){r3dakka=0;}}
             else if (azalt==0){delay_ms(200);r3dakka--;if (r3dakka<=-1){r3dakka=59;}}
      break;

   }}

   }
 void bas4()
    {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
     case 0:
            txt1[1]=(r4saat%10)+48;
            txt1[0]=(r4saat/10)+48;
            Lcd_Out(1,1,txt3);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
            if (arttir==0){delay_ms(200);r4saat++;if (r4saat>=24){r4saat=0;}}
            else if (azalt==0){delay_ms(200);r4saat--;if (r4saat<=-1){r4saat=23;}}
      break;

     case 1:
            txt2[1]=(r4dakka%10)+48;
            txt2[0]=(r4dakka/10)+48;
            Lcd_Out(1,1,txt4);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
             if (arttir==0){delay_ms(200);r4dakka++;if (r4dakka>=60){r4dakka=0;}}
             else if (azalt==0){delay_ms(200);r4dakka--;if (r4dakka<=-1){r4dakka=59;}}
      break;

   }}

   }
 void bas5()
    {
      while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
     case 0:
            txt1[1]=(r5saat%10)+48;
            txt1[0]=(r5saat/10)+48;
            Lcd_Out(1,1,txt3);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);

            if (arttir==0){delay_ms(200);r5saat++;if (r5saat>=24){r5saat=0;}}
            else if (azalt==0){delay_ms(200);r5saat--;if (r5saat<=-1){r5saat=23;}}
      break;

     case 1:
            txt2[1]=(r5dakka%10)+48;
            txt2[0]=(r5dakka/10)+48;
            Lcd_Out(1,1,txt4);
            Lcd_Out(2,4,txt2);
            Lcd_Out(2,3,":");
            Lcd_Out(2,1,txt1);
             if (arttir==0){delay_ms(200);r5dakka++;if (r5dakka>=60){r5dakka=0;}}
             else if (azalt==0){delay_ms(200);r5dakka--;if (r5dakka<=-1){r5dakka=59;}}
      break;

   }}

   }
  void bitis1()
     {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
    case 0:
          txt7[1]=(rb1saat%10)+48;
          txt7[0]=(rb1saat/10)+48;
          Lcd_Out(1,1,txt5);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb1saat++;if (rb1saat>=24){rb1saat=0;}}
          else if (azalt==0){delay_ms(200);rb1saat--;if (rb1saat<=-1){rb1saat=23;}}
   break;

   case 1:
          txt8[1]=(rb1dakka%10)+48;
          txt8[0]=(rb1dakka/10)+48;
          Lcd_Out(1,1,txt6);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb1dakka++;if (rb1dakka>=60){rb1dakka=0;}}
          else if (azalt==0){delay_ms(200);rb1dakka--;if (rb1dakka<=-1){rb1dakka=59;}}
   break;

   }}

   }
 void bitis2()
     {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
    case 0:

          txt7[1]=(rb2saat%10)+48;
          txt7[0]=(rb2saat/10)+48;
          Lcd_Out(1,1,txt5);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb2saat++;if (rb2saat>=24){rb2saat=0;}}
          else if (azalt==0){delay_ms(200);rb2saat--;if (rb2saat<=-1){rb2saat=23;}}
   break;

   case 1:
          txt8[1]=(rb2dakka%10)+48;
          txt8[0]=(rb2dakka/10)+48;
          Lcd_Out(1,1,txt6);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb2dakka++;if (rb2dakka>=60){rb2dakka=0;}}
          else if (azalt==0){delay_ms(200);rb2dakka--;if (rb2dakka<=-1){rb2dakka=59;}}
   break;

   }}

   }
 void bitis3()
     {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
    case 0:

          txt7[1]=(rb3saat%10)+48;
          txt7[0]=(rb3saat/10)+48;
          Lcd_Out(1,1,txt5);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb3saat++;if (rb3saat>=24){rb3saat=0;}}
          else if (azalt==0){delay_ms(200);rb3saat--;if (rb3saat<=-1){rb3saat=23;}}
   break;

   case 1:
          txt8[1]=(rb3dakka%10)+48;
          txt8[0]=(rb3dakka/10)+48;
          Lcd_Out(1,1,txt6);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb3dakka++;if (rb3dakka>=60){rb3dakka=0;}}
          else if (azalt==0){delay_ms(200);rb3dakka--;if (rb3dakka<=-1){rb3dakka=59;}}
   break;

   }}

   }
 void bitis4()
     {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
    case 0:

          txt7[1]=(rb4saat%10)+48;
          txt7[0]=(rb4saat/10)+48;
          Lcd_Out(1,1,txt5);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb4saat++;if (rb4saat>=24){rb4saat=0;}}
          else if (azalt==0){delay_ms(200);rb4saat--;if (rb4saat<=-1){rb4saat=23;}}
   break;

   case 1:
          txt8[1]=(rb4dakka%10)+48;
          txt8[0]=(rb4dakka/10)+48;
          Lcd_Out(1,1,txt6);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb4dakka++;if (rb4dakka>=60){rb4dakka=0;}}
          else if (azalt==0){delay_ms(200);rb4dakka--;if (rb4dakka<=-1){rb4dakka=59;}}
   break;

   }}

   }
 void bitis5()
     {
     while(ayar<2)
   {
    if(set==0){delay_ms(200);ayar++;}
    switch(ayar){
    case 0:

          txt7[1]=(rb5saat%10)+48;
          txt7[0]=(rb5saat/10)+48;
          Lcd_Out(1,1,txt5);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb5saat++;if (rb5saat>=24){rb5saat=0;}}
          else if (azalt==0){delay_ms(200);rb5saat--;if (rb5saat<=-1){rb5saat=23;}}
   break;

   case 1:
          txt8[1]=(rb5dakka%10)+48;
          txt8[0]=(rb5dakka/10)+48;
          Lcd_Out(1,1,txt6);
          Lcd_Out(2,4,txt8);
          Lcd_Out(2,3,":");
          Lcd_Out(2,1,txt7);
          if (arttir==0){delay_ms(200);rb5dakka++;if (rb5dakka>=60){rb5dakka=0;}}
          else if (azalt==0){delay_ms(200);rb5dakka--;if (rb5dakka<=-1){rb5dakka=59;}}
   break;

   }}

   }
     void display(){
 //Split data into two parts
  saniye10  =  (saniye & 0x70) >> 4;
  saniye = saniye & 0x0F;
  dakika10  =  (dakika & 0x70) >> 4;
  dakika = dakika & 0x0F;
  saat10  =  (saat & 0x30) >> 4;
  saat = saat & 0x0F;
  tarih10  =  (tarih & 0x30) >> 4;
  tarih = tarih & 0x0F;
  ay10  =  (ay & 0x10) >> 4;
  ay = ay & 0x0F;
  yil10  =  (yil & 0xF0) >> 4;
  yil = yil & 0x0F;
  //Display Time
  Lcd_Chr(1, 11, saniye + 48);
  Lcd_Chr(1, 10, saniye10 + 48);
  Lcd_Chr(1, 8, dakika + 48);
  Lcd_Chr(1, 7, dakika10 + 48);
  Lcd_Chr(1, 5, saat + 48);
  Lcd_Chr(1, 4, saat10 + 48);
  //Display calendar
  Lcd_Chr(2, 5, tarih + 48);
  Lcd_Chr(2, 4, tarih10 + 48);
  Lcd_Chr(2, 8, ay + 48);
  Lcd_Chr(2, 7, ay10 + 48);
  Lcd_Chr(2, 13, yil + 48);
  Lcd_Chr(2, 12, yil10 + 48);
  }
 
 void write_value(char address, char data_){
   Soft_I2C_Start();        // Start I2C signal
   Soft_I2C_Write(0xD0);    // DS1307 address
   Soft_I2C_Write(address);
   Soft_I2C_Write(data_);
   Soft_I2C_Stop();     }
   
 void main() {
 ADCON1=0x07;
 TRISA=0xFF;
 PORTA=0;
  bas:
 Lcd_Init();                // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR);       // Clear LCD display
 Lcd_Cmd(_LCD_CURSOR_OFF);  // Turn cursor off
 Soft_I2C_Init();
 /*
 write_value(1, 0x18);    //Write minutes
 write_value(2, 0x11);    //Write hours
 write_value(4, 0x14);    //Write date
 write_value(5, 0x03);    //Write month
 write_value(6, 0x15);    //Write year
 write_value(7, 0x10);    //Set SQW output at 1Hz
 write_value(0, 0);   //Reset seconds and start oscillator
 */

 Lcd_Out(1, 6, ":  :");
 Lcd_Out(2, 6, "/  /20");

 while(1){
 Soft_I2C_Start();         // Start I2C signal
 Soft_I2C_Write(0xD0);     // DS1307 address
 Soft_I2C_Write(0);        //Start from reg0
 Soft_I2C_Start();
 Soft_I2C_Write(0xD1);   // DS1307 read data address
  saniye = Soft_I2C_Read(1);   // Read seconds
  dakika = Soft_I2C_Read(1);   // Read minutes
  saat = Soft_I2C_Read(1);     // Read hours
  gun = Soft_I2C_Read(1);      // Read day
  tarih = Soft_I2C_Read(1);     // Read date
  ay = Soft_I2C_Read(1);    // Read month
  yil = Soft_I2C_Read(0);     // Read year
  Soft_I2C_Stop();             // Stop I2C signal
  display();            //Display time on LCD


  if(set==0)
  {
  delay_ms(200);
  Lcd_Cmd(_LCD_CLEAR);
  goto don
  }
  }
 don:
 while(1){
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1,1, "AYARLAR");
 for(;;)
 {
 if (arttir==0){delay_ms(200);ayarmenu++;}
 else if(ayarmenu>=7){ayarmenu=1;}


 switch (ayarmenu)
   {
  case 1: Lcd_Out(2,1, "ROLE-1");
           if (set==0){delay_ms(200);goto rolebir;}
           break;
  case 2: Lcd_Out(2,1, "ROLE-2");
           if (set==0){delay_ms(200);goto roleiki;}
           break;
  case 3: Lcd_Out(2,1, "ROLE-3");
           if (set==0){delay_ms(200);goto roleuc;}
           break;
  case 4: Lcd_Out(2,1, "ROLE-4");
           if (set==0){delay_ms(200);goto roledort;}
           break;
  case 5: Lcd_Out(2,1, "ROLE-5");
           if (set==0){delay_ms(200);goto rolebes;}
           break;

  case 6: Lcd_Out(1,1, "ANA PROGRAMA");
               Lcd_Out(2,1, "----DON----");
               if (set==0){delay_ms(200);ayarmenu=1;goto bas;}
               break;
  case 7: Lcd_Cmd(_LCD_CLEAR);goto don;
       break;
   }  }}

   rolebir:
   while(1)
   {  Lcd_Cmd(_LCD_CLEAR);bas1();ayar=0;
      Lcd_Cmd(_LCD_CLEAR);bitis1();ayar=0;

      goto don;
     }
   roleiki:
   while(1)
   {  
      Lcd_Cmd(_LCD_CLEAR);bas2();ayar=0;
      Lcd_Cmd(_LCD_CLEAR);bitis2();ayar=0;
      goto don;
     }
   roleuc:
   while(1)
   { 
       Lcd_Cmd(_LCD_CLEAR);bas3();ayar=0;
       Lcd_Cmd(_LCD_CLEAR);bitis3();ayar=0;
       goto don;
     }
   roledort:
   while(1)
   { 
      Lcd_Cmd(_LCD_CLEAR);bas4();ayar=0;
      Lcd_Cmd(_LCD_CLEAR);bitis4();ayar=0;
      goto don;
     }
   rolebes:
   while(1)
   {  
      Lcd_Cmd(_LCD_CLEAR);bas4();ayar=0;
      Lcd_Cmd(_LCD_CLEAR);bitis4();ayar=0;
      goto don;
     }
}

mustafa_cmbz

sbit LCD_D4_Direction at TRISB2_bit;
 sbit LCD_D5_Direction at TRISB3_bit;
 sbit LCD_D6_Direction at TRISB4_bit;
 sbit LCD_D7_Direction at TRISB5_bit;


c bilmiyorum fakat gözüme ilişen lcd nin data portlarını port2 den başlayarak vermişsin.Data portlarını
sbit LCD_D4_Direction at TRISB4_bit;
 sbit LCD_D5_Direction at TRISB5_bit;
 sbit LCD_D6_Direction at TRISB6_bit;
 sbit LCD_D7_Direction at TRISB7_bit;



digger kısmıda bu şekilde düzenleyip bir denermisin.

Yücel BOZDEMİR

Değişikliği yaptım ancak herhangi bir değişiklik olmadı.

// LCD module connections
 sbit LCD_RS at RB0_bit;
 sbit LCD_EN at RB1_bit;
 sbit LCD_D4 at RB4_bit;
 sbit LCD_D5 at RB5_bit;
 sbit LCD_D6 at RB6_bit;
 sbit LCD_D7 at RB7_bit;
 sbit LCD_RS_Direction at TRISB0_bit;
 sbit LCD_EN_Direction at TRISB1_bit;
 sbit LCD_D4_Direction at TRISB4_bit;
 sbit LCD_D5_Direction at TRISB5_bit;
 sbit LCD_D6_Direction at TRISB6_bit;
 sbit LCD_D7_Direction at TRISB7_bit;