资源简介

主要包含程序,可以帮助学习高端单片机控制LCD显示的方法,程序基于C语言编写,具有很强的可读性以及可移植性!

资源截图

代码片段和文件信息

#include “c8051f020.h“
//#include “LCDLong.H“
#include “intrins.h“
#include “lcd.h“
 //***************AD_DA配置************************
void AD_DA_Config(void)
{

WDTCN=0X07;
WDTCN=0XDE;
WDTCN=0XAD; //关开门狗

XBR0=0XAF;
XBR1=0X0D;
XBR2=0X44; // 端口分配表见说明文件

OSCXCN=0X00;
OSCICN=0x06; //内部8m晶振

REF0CN = 0x03; // Reference Control Register

//----------------------------------------------------------------
// ADC Configuration  AMUX0:九通道的可编程模拟多路选择器ADC0的最高转换速率为100ksps其转换时钟来源与系统
//时钟分频分频值保存在寄存器ADC0CF的ADCSC位.

//----------------------------------------------------------------

AMX0CF = 0x60; // AMUX Configuration Register                      配置寄存器
AMX0SL = 0x00; // AMUX Channel Select Register   AMX0SL =0x00;     //选择通道0  AMX0SL通道选择寄存器
ADC0CF = 0x18; // ADC Configuration Register  配置寄存器
ADC0CN = 0x80; // ADC Control Register  控制寄存器

ADC0LTH = 0x00; // ADC Less-Than High Byte Register   ****下限寄存器ADC0GTH
ADC0LTL = 0x00; // ADC Less-Than Low Byte Register   ****下限寄存器ADC0GTL
ADC0GTH = 0xFF; // ADC Greater-Than High Byte Register
ADC0GTL = 0xFF; // ADC Greater-Than Low Byte Register

     /*AMX1SL = 0x00;  // AMUX1 Channel Select Register   
     ADC1CF = 0xF8;  // ADC1 Configuration Register
     ADC1CN = 0x00;  // ADC1 Control Register



DAC0CN = 0x80; // DAC0 Control Register
DAC0L = 0x00; // DAC0 Low Byte Register
DAC0H = 0x00; // DAC0 High Byte Register

DAC1CN = 0X80;
DAC1L = 0X00;
DAC1H = 0X00; */


}

/****************************************************************
DAC0 DAC1  OUTPUT function
*****************************************************************/

void DA0_Out (unsigned int con_volt  )
{
unsigned char hbytelbyte;

hbyte=con_volt/256;
lbyte=con_volt&0x00ff;

DAC0L=lbyte;
DAC0H=hbyte;
}

void DA1_Out (unsigned int con_volt)
{
unsigned char hbytelbyte;

hbyte=con_volt/256;
lbyte=con_volt&0x00ff;

DAC1L=lbyte;
DAC1H=hbyte;
}

/************************************************************
ADC0 ADC1 output function 
**********************************************************/

unsigned int  AD_Sample ( )
{

unsigned char hbytelbyte;
unsigned char i;
unsigned int  current_vlot=0;
unsigned int  ret_volt=0;

for(i=0;i<8;i++)
{
AD0BUSY=1; //start ADC0 convert

while(!AD0INT); // waitting
hbyte=ADC0H;
lbyte=ADC0L;

current_vlot=hbyte*256+lbyte;

ret_volt=( current_vlot>>3)+ret_volt;
}
 
return ret_volt;

}


void Delay_ADDA(unsigned int counter)
{
while(counter--);
}

 


main()

{
unsigned int i=0;
unsigned int voltage=0;
float temp=0;
AD_DA_Config();

while(1)
{

DA0_Out (1000 );

DA1_Out (2000 );


Delay_ADDA(10000);
temp=AD_Sample ( ); 
Delay_ADDA(100);

temp=(temp*2420)/4096;

LCD_WriteCommand(0x0c);
LCD_Config( );
LCD_Init( ); 
LCD_ChangMode(0);
LCD_Printf(11“TI_UESTC“);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2936  2008-10-20 16:39  c8051f020LCD\AD\AD_DA.C

     文件        276  2008-10-20 15:14  c8051f020LCD\AD\AD_DA.H

     文件      26167  2008-10-20 18:56  c8051f020LCD\LCD\AD

     文件       3332  2008-10-20 18:59  c8051f020LCD\LCD\AD.c

     文件      14179  2008-10-20 18:56  c8051f020LCD\LCD\AD.hex

     文件         52  2008-10-20 18:56  c8051f020LCD\LCD\AD.lnp

     文件       7602  2008-10-20 18:56  c8051f020LCD\LCD\AD.LST

     文件      27570  2008-10-20 18:56  c8051f020LCD\LCD\AD.M51

     文件       9066  2008-10-20 18:56  c8051f020LCD\LCD\AD.OBJ

     文件      34383  2008-10-20 18:56  c8051f020LCD\LCD\AD.plg

     文件      14062  2008-10-18 20:09  c8051f020LCD\LCD\CONFIG_LCD.H

     文件      19218  2008-10-20 16:09  c8051f020LCD\LCD\LCD

     文件      29290  2008-10-18 22:42  c8051f020LCD\LCD\LCD.C

     文件       2417  2008-10-20 17:53  c8051f020LCD\LCD\LCD.H

     文件      11455  2008-10-20 16:09  c8051f020LCD\LCD\LCD.hex

     文件         51  2008-10-20 16:09  c8051f020LCD\LCD\LCD.lnp

     文件      46211  2008-10-20 15:12  c8051f020LCD\LCD\LCD.LST

     文件      19512  2008-10-20 16:09  c8051f020LCD\LCD\LCD.M51

     文件      19054  2008-10-20 15:12  c8051f020LCD\LCD\LCD.OBJ

     文件       3627  2008-10-20 18:59  c8051f020LCD\LCD\LCD.Opt

     文件       9293  2008-10-20 16:09  c8051f020LCD\LCD\LCD.plg

     文件       2259  2008-10-20 18:59  c8051f020LCD\LCD\LCD.Uv2

     文件      29840  2008-10-20 17:53  c8051f020LCD\LCD\LCDLong.C

     文件      47181  2008-10-20 18:56  c8051f020LCD\LCD\LCDLong.LST

     文件      19793  2008-10-20 18:56  c8051f020LCD\LCD\LCDLong.OBJ

     文件       2181  2008-10-20 17:53  c8051f020LCD\LCD\LCD_Opt.Bak

     文件       2259  2008-10-20 17:53  c8051f020LCD\LCD\LCD_Uv2.Bak

     文件        478  2008-10-20 17:42  c8051f020LCD\LCD\test.c

     文件       1847  2008-10-20 17:33  c8051f020LCD\LCD\test.LST

     文件       2828  2008-10-20 17:33  c8051f020LCD\LCD\test.OBJ

............此处省略10个文件信息

评论

共有 条评论