⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functii_lcd.c~

📁 avr Rtos 255 Task avr Rtos 255 Task
💻 C~
字号:
#include <mega128.h>
static char screenpos[4][20] = {
                                {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
                                 0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93},
                                {0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,
                                 0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3},
                                {0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,
                                 0x9E,0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7},
                                {0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,
                                 0xDE,0xDF,0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7}
                               };  

void temp()
{ 
 int t;
   //dezactivare LCD
  WritePortD(0x00,0x10);//0xx
  //scriere 0 linii
  WritePortA(0x00,0xFF);//data=0
  SetPortA_In(0xFF);//setare port A intrare
  //configurare citire LCD comanda
  WritePortD(0x20,0x70);//010//configurare citire

 for(t=0;t<50;t++);//temporizare
  WritePortD(0x10,0x10);//1xx
  // //activare LCD
  //  MA_WritePort_IO(MA_PORTG,0x00,0x04);
  ///////////////////////////////////////////////////debugbuton

//do{
 //citire busy flag
 //t=PINA;
 //}while(t&0x80);
 //MA_WritePort_IO(MA_PORTE,0xFF,0xFF);//data
 WritePortD(0x00,0x10);//000
 for(t=0;t<50;t++);//temporizare
  WritePortD(0x00,0x70);//000
  SetPortD_In(0x70);//setare port intrare
}

void send_command (const char s)
{ int temp_g;

  
  PORTD=0x00;  //000
  DDRA=0xFF;//setare port A iesire
  DDRD=0xFF;//setare port G iesire

  PORTA=s;//comanda
  PORTD=0x10;  //100
  for(temp_g=0;temp_g<50;temp_g++);//temporizare
  //temp();
}

void send_char (const char s)
{   
  int t;
  //temp();
  WritePortD(0x00,0x70);  //000
  SetPortA_Out(0xFF);//setare port A iesire
  SetPortD_Out(0x70);//setare port G iesire  

  WritePortA(s,0xFF);//data
  WritePortD(0x50,0x70);  //101 scriere data   
  
  for(t=0;t<50;t++);//temporizare
  temp(); 
}

void init()
{
//init_LCD();
  int temp_g;
  int ig;
  //initializare lcd
  DDRA=0xFF;//setare port A iesire
  DDRD=0xFF;//setare port G iesire
  //MA_WritePort_IO(MA_PORTG,0x00,0x07);  //000

  PORTD=0x10; //E=1 enable
  for(temp_g=0;temp_g<200;temp_g++);//temporizare

  //temp();
  for(ig=0;ig<3;ig++)
  {
   send_command(0x3c);//function Set : 8bits 2line on
   for(temp_g=0;temp_g<200;temp_g++);//temporizare
  }
   send_command(0x0F);//Display on
   for(temp_g=0;temp_g<200;temp_g++);//temporizare

   send_command(0x01);//Display clear
   for(temp_g=0;temp_g<200;temp_g++);//temporizare

   send_command(0x06);//Entry mode select
   for(temp_g=0;temp_g<200;temp_g++);//temporizare

 //  MA_WritePort_IO(MA_PORTE,0xFF,0xFF);//data

  // send_command(0x0f);//Display on
   //for(temp_g=0;temp_g<200;temp_g++);//temporizare
//End initializare
}   

void send_string (char *str) {			// sends the whole string to LCD
 while ((*str != 0)&& (*str != 10))
   send_char (*str++);
}

void setpos (char x,char y) {
 send_command (screenpos[x-1][y-1]);
}  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -