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

📄 main.c

📁 内外差值法
💻 C
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include <MC9S08AW60.h>
//#include "DS18B20.h"
//#include "NH12864.h"

//char  sensor_temp_disp[]="000.00";
// int i;

#define LCD_DATA_PORT PTBD
#define RS PTDD_PTDD4
#define RW PTDD_PTDD5
#define EN PTDD_PTDD6


#define LOW  0
#define HIGH 1

#define Clear_screen        0x01
#define Disp_on             0x0c
#define Disp_off            0x08

#define Cursor_on           0x0e
#define Cursor_off          0x0c
#define Cursor_flicker_on   0x0f
#define Cursor_flicker_off  0x0e


  

 void LCD_delay(unsigned char d)
 {
    while(d--)
    {
      __RESET_WATCHDOG();
    }
 } 

void MCU_Init(void)
{
   ICGC1=0X78;
   ICGC2=0X01;
}

void Lcd12864_Write_Data(char Data)
{
  //Lcd12864_Check_Busy();    
    RS=HIGH;
    RW=LOW;
  // write_164(Data);
    LCD_DATA_PORT=Data;
    LCD_delay(100);
    EN=HIGH;
    LCD_delay(100);
    EN=LOW;
  // write_164(0xFF);
    LCD_DATA_PORT=0xFF; 
    LCD_delay(100);
    LCD_delay(100);
}

void Lcd12864_Write_Command(char Command_Code)
{
    RS=LOW;
    RW=LOW;
    LCD_DATA_PORT=Command_Code;
    LCD_delay(100);
    EN=HIGH ;
    LCD_delay(100);
    EN=LOW;
    LCD_delay(100);
    LCD_delay(100);      
}

void Lcd12864_set_xy(unsigned char x, unsigned char y)
{
    unsigned char p;
    switch(x)
    {
        case 0: p = 0x80; break; //第一行开始地址
        case 1: p = 0x88; break; //第二行
        case 2: p = 0x90; break; //第三行
        case 3: p = 0x98; break; //第四行
    }
    p += y;
    __RESET_WATCHDOG();
    Lcd12864_Write_Command(p);
}	 

void Lcd12864_Write_words(char x, char y, char *str)
{
    unsigned char i = 0;
    Lcd12864_set_xy(x,y);
    while(str[i] != '\0')
    {
        Lcd12864_Write_Data(str[i++]);
        //__RESET_WATCHDOG();
    }
}



void Lcd12864_Int(void)
{
    LCD_delay(20);
    Lcd12864_Write_Command(0x30);
    LCD_delay(20);
    Lcd12864_Write_Command(Disp_on);  /*开显示,不显示光标*/
    LCD_delay(20);
    Lcd12864_Write_Command(Clear_screen);  /*显示清屏。*/
    LCD_delay(20);
    Lcd12864_set_xy(0,0);
}

/*void temperature(void)
{ 
     sensor_temp_disp[0]=temp_value_int/100+'0';
	   sensor_temp_disp[1]=temp_value_int%100/10+'0';
	   sensor_temp_disp[2]=temp_value_int%10+'0';
	   
	   sensor_temp_disp[4]=temp_value_float/10+'0';
	   sensor_temp_disp[5]=temp_value_float%10+'0';	    
}  */

void main(void) 
{
   //SOPT_COPE=0;
  MCU_Init(); 
   //Start_18b20();
  
  //Lcd12864_Int();

  
  PTBDD=0XFF;
  PTDDD=0XFF; 
  Lcd12864_Int();
  Lcd12864_Write_Command(Clear_screen);  /*显示清屏。*/

  Lcd12864_set_xy(0,0);  
  

  //for(i=1000;i>0;i--);
  Lcd12864_Write_words(0,0,"基于PIC 倾角测量"); 
  //Lcd12864_Write_words(0,0,"PICC"); 
  Lcd12864_Write_words(1,0,"当前角度:15.2"); 
   //Get_temp_value();
   //temperature(); 
   //Lcd12864_Write_words(0,3,sensor_temp_disp); 
/* put your own code here */
   for(;;) {
    __RESET_WATCHDOG();
   }/* feeds the dog */
  /* please make sure that you never leave this function */
}

⌨️ 快捷键说明

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