اطلاعیه

Collapse
No announcement yet.

راه اندازی glcd ts112864a-2

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    راه اندازی glcd ts112864a-2

    سلام دوستان .من یه glcd به شماره ts12864a-2 دارمولی نمی تونم راه اندازیش کنم .کسی میتونه به من کمک کنه لطفا با بسکام یه مثال بزارید + ترتیب پایه ها

    #2
    پاسخ : راه اندازی glcd ts112864a-2

    سلام
    منم مثل بقیه در راه اندازی glcd ها به مشکل خوردم.
    برنامه به زبان c توی codvision هست و در پروتئوس جواب داده نمیدونم چرا در سخت افزار جواب نمیده.
    تغذیه ها هم چک کردم.

    دیدگاه


      #3
      پاسخ : راه اندازی glcd ts112864a-2

      #include <mega32.h>
      #include <delay.h>
      #include <stdio.h>
      #define LCD_RS PORTC.0
      #define LCD_RW PORTC.1
      #define LCD_E PORTC.2
      #define LCD_CS1 PORTC.3
      #define LCD_CS2 PORTC.4
      #define LCD_RST PORTC.5
      #define DDR_DATA DDRB
      #define DATAPORT PORTB
      #define DATAPIN PINB
      //______________________________

      const unsigned char num[128] = {0,127,127, 65, 65,127,127, 0, //0
      0, 0, 0, 6,126,126, 0, 0, //1
      0, 0,123,123,107,111,111, 0, //2
      0,107,107,107,107,127,127, 0, //3
      0, 15, 15, 8, 8,127,127, 0, //4
      0,111,111,107,107,123,123, 0, //5
      0,127,127, 73, 73,121,121, 0, //6
      0, 7, 7, 3,127,127, 0, 0, //7
      0,127,127, 73, 73,127,127, 0, //8
      0, 79, 79, 73, 73,127,127, 0, //9
      0,127,127, 19, 19,127,127, 0, //A
      0,127,127, 73, 73, 73, 62, 0, //B
      0,127,127, 99, 99, 99, 0, 0, //C
      0,127,127, 65, 65, 65, 62, 0, //D
      0,127,127, 73, 73, 73, 65, 0, //E
      0,127,127, 27, 27, 3, 3, 0 //F

      };
      const unsigned char ATMEl[1024] = {
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,192,240, 16,176, 48, 32,176,112, 32,128, 0, 0, 0, 0, 0,
      128,128,128,128,128,128,128,240, 56, 24,248, 8,200, 8, 48, 0,
      192,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0,192,192, 32, 32, 32, 16, 16, 16, 0, 8, 14,
      31, 23, 33, 64,129, 2, 4, 15, 16, 8, 7, 1,123, 3, 3, 5,
      121,225, 65, 64, 64, 64, 64, 65, 65,194,194,197, 67, 72, 82,113,
      33, 63,188,128, 1, 31, 60, 32, 64, 64,128,128,128, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      128,128, 64, 32, 0, 16, 0, 8, 8, 8, 8, 8, 8,200, 24, 8,
      8, 8,104, 24, 24, 24, 48, 96,192, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0,192,254,127, 0, 1, 0, 2, 4, 8, 16, 32, 64,128,
      128, 64, 64, 32, 32, 17, 26, 12, 28, 36,196, 2, 3, 0, 0,224,
      16, 8,196, 50, 40, 5, 5,194, 38, 64,160, 17,185,145,145,153,
      129,146,148, 48,114,194,192,157,140, 26, 36, 68, 9,145,103,140,
      56, 96,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 48, 24, 4,194,
      33, 16, 0, 4, 4,128,194, 64, 0, 32, 0, 2, 66, 76, 64, 0,
      0, 1, 14, 48, 0, 1, 32,124, 15, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 1, 3, 2, 4, 4, 6, 4, 8, 24, 48, 32, 64,
      192,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 16, 64,135,
      8, 32, 7, 76, 80,168, 32, 0, 64, 2, 5,130,133,136,136, 16,
      16, 24,136,140,134, 5, 67, 98, 8, 0, 4,140, 64, 33, 16, 7,
      0, 0, 1, 3, 14, 24, 48,192,128, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0,224, 28, 7, 1,128,112, 12, 3,128,
      128, 0,112, 12, 66, 65, 64, 64,128, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 0,224,
      192,208,129,218, 38, 4, 0, 16, 48, 32, 64,192,128, 0, 0, 1,
      6, 8,112, 16, 32, 0, 0, 1, 16,144,146,146,144,144,128,128,
      128, 0, 0, 66, 66, 74, 72, 72, 73, 72, 64, 0, 0, 32, 32, 36,
      36, 36, 36,100, 68, 64, 64, 64, 1, 63, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0,255,129, 0, 0, 0, 0, 1, 0, 0, 0,
      15, 96,128, 0, 0, 30, 32,128, 0, 3, 22, 12,112,128, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 8, 2, 0,128,202,
      47, 25, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2,
      4, 4, 4, 4, 4, 0, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 3, 2, 4, 0, 8, 0, 16, 16, 16,
      224, 0,192, 17,148, 24, 0, 16, 17, 2, 4,140,136, 15, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0,128,128, 64, 0, 96, 32, 56, 24, 9,141, 36, 36, 0, 5, 1,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 2, 0, 0, 0, 0, 4, 2, 5, 8, 2, 4, 0, 8, 4, 8,
      1, 3, 24, 5, 24, 20, 16, 28, 0, 22, 0, 8, 1, 9, 0, 8,
      8, 7, 8, 1, 4, 0, 7, 2, 3, 1, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      };

      //______________________________
      //__Trigger_____________________

      void trigger(void)
      {
      LCD_E = 1; //EN high
      delay_us(5);
      LCD_E = 0; //EN low
      delay_us(5);
      }

      //______________________________
      //__Read Data___________________
      char DATA_R(){
      unsigned char buffer;
      DDR_DATA=0x00; //make Input
      DATAPORT=0xFF;
      delay_us(1);
      LCD_RS = 1; //RS high --> data
      LCD_RW = 1; //RW high --> read
      trigger();
      LCD_E=1;
      delay_us(1);
      buffer=DATAPIN;
      delay_us(1);
      LCD_E=0;
      DDR_DATA=0xFF; //make Output
      delay_us(1);
      return buffer;
      }
      //______________________________
      //__Write Data__________________
      void DATA_W(char DATA){
      LCD_E=0;
      LCD_RW=0;
      delay_us(10);
      LCD_RS=1;
      DATAPORT=DATA;
      LCD_E=1;
      delay_us(10);
      LCD_E=0;
      }
      //______________________________
      //__Write Command_______________
      void COMMAND_W(char COMM){
      LCD_E=0;
      LCD_RW=0;
      delay_us(10);
      LCD_RS=0;
      DATAPORT=COMM;
      LCD_E=1;
      delay_us(10);
      LCD_E=0;
      }
      //______________________________
      //__Chip Select_________________
      void CHIP_SEL(char CHIP){
      LCD_E=0;
      LCD_RW=0;
      if(CHIP==0){
      LCD_CS1=1;
      LCD_CS2=0;
      }

      else{
      LCD_CS1=0;
      LCD_CS2=1;
      }
      }
      //______________________________
      //__LCD Init____________________
      void LCD_INIT(void){

      COMMAND_W(0x3F); //Display ON
      COMMAND_W(0xB8); //X Address => 0
      COMMAND_W(0xC0); //Display Start Line => 0
      COMMAND_W(0x40); //Y Address => 0
      }
      //______________________________
      //______________________________
      void lcd_show(void){
      unsigned char i,j;
      unsigned int m;
      CHIP_SEL(0);
      LCD_INIT();
      m=0;
      while(m<=1023){
      for(j=0;j<8;j++){
      COMMAND_W(0b10111000+j);
      for(i=0;i<=63;i++){
      DATA_W(ATMEl[m]);
      m++;
      }
      m=m+64;
      }
      }
      m=64;
      CHIP_SEL(1);
      LCD_INIT();
      while(m<=1023){
      for(j=0;j<8;j++){
      COMMAND_W(0b10111000+j);
      for(i=0;i<=63;i++){
      DATA_W(ATMEl[m]);
      m++;
      }
      m=m+64;
      }
      }

      }
      //______________________________
      //______________________________
      char spix(char x,char y ){
      unsigned char j,i,y_1,box=0;
      if(x<=63){
      CHIP_SEL(0);
      }
      else{
      CHIP_SEL(1);
      x=x-64;
      }
      y_1=y/8;
      i=y%8;
      y=0b00000001;
      for(j=0;j<i;j++){
      y=y<<1;
      }
      COMMAND_W(0x40+x);
      COMMAND_W(0xB8+y_1);
      box=DATA_R();
      box=box|y;
      y=~y;
      COMMAND_W(0x40+x);
      COMMAND_W(0xB8+y_1);
      DATA_W(box);

      }
      //______________________________
      //__LCD Clear___________________
      void glcd_clear(){
      char i,j,k;
      for(k=0;k<2;k++){
      CHIP_SEL(k);
      for(i=0;i<8;i++){
      COMMAND_W(0xB8+i);
      COMMAND_W(0x40);
      for(j=0;j<64;j++){
      DATA_W(0x00);
      //delay_ms(50);
      }
      }
      }
      }
      //_______________________________
      //__MAIN PROGRAM_________________
      void main(){
      DDRB=0xff;
      DDRC=0xFF;
      LCD_RST=1;
      delay_ms(500);
      lcd_show();
      delay_ms(2000);
      glcd_clear();
      spix(0,0);
      spix(0,6);
      spix(0,7);
      spix(126,7);
      spix(65,57);
      spix(32,35);
      spix(110,22);
      spix(110,24);
      spix(110,26);
      }
      این برنامه نوشتم تست کردم جواب میده

      دیدگاه

      لطفا صبر کنید...
      X