珩源电子
加入收藏 联系我们 繁體中文
公 告:    2019-5月新品上市  本公司所有产品的相关说明书下载位置!  本站承担过项目简介,欢迎合作交流!
珩源首页

资料下载

电子中心

新闻资讯 客户服务 游客留言 联系我们

技术论坛

登录
最新下载
Stm32F103vctb数控原...
简易并口ISSP编程器
Cypress CY21434 ...
PSoC_ISSP编程器(USB...
中文资料列表
AD7705程序以及开发参考资料...
AD7705程序以及开发参考资料...
步进电机控制器
 雕刻机控制器卡
 专用步进电机控制器
 通用步进电机控制器
步进电机驱动器
 板式步进电机驱动器
 盒式步进电机驱动器
步进电机
 二相42步进电机
 三相110步进电机
 二相86步进电机
 二相57步进电机
专用领域产品
动力锂电池保护板
开发板
 STM32开发板
 can通信模块
 ATMEGA 8功能板
开关电源
    你希望了解的是什么?
STM32开发板
单片机资料
锂电池保护
动力蓄电池检测系统
电子元器件价格
单片机新闻咨询
汽车参数检测与语音报警
单片机开发板

  
下载中心
AVR单片机 >> AD7705程序以及开发参考资料11

AD7705程序以及开发参考资料11

 资料分类:AVR单片机 |
AD7705程序以及开发参考资料11
 文件大小:
 运行环境:WIN98, WIN2000, WIN XP
 整理日期:2009-7-21
 下载次数:5029
::下载地址::
 ┊下载地址┊ ┊备用下载地址一┊ ┊备用下载地址二
::下载说明::
#include <avr/io.h>
#include <avr/delay.h>

//控制端口
#define LCD_CTRL_DDR  DDRB
#define LCD_CTRL_PORT PORTB
#define LCD_CTRL_PIN  PINB
#define LCD_RS   0X01
#define LCD_RW   0X02
#define LCD_EN   0X04
//读取类型
#define read_comm   0
#define read_data   1
//数据端口
#define LCD_DATA_DDR  DDRA
#define LCD_DATA_PORT PORTA
#define LCD_DATA_PIN  PINA

void lcd_init(void);                       //LCD初始化
void lcd_write_comm(unsigned char comm);  //写命令
void lcd_write_data(unsigned char data);  //写数据
void lcd_write_str(unsigned char x,unsigned char y,unsigned char *p);     //写字符串
unsigned char lcd_read_char(unsigned char read_type);  //读取
void lcd_posion(unsigned char x,unsigned char y);     //位置设定
void lcd_busy_chek(void);
void lcd_en_signal(void);

void lcd_init(void)
{   
   LCD_CTRL_PORT=0x00;
   LCD_CTRL_DDR= 0xff;   
   LCD_DATA_PORT=0X00;
   LCD_DATA_DDR=0XFF;   
   lcd_write_comm(0x3f); //功能设置,8位数据,两行显示,5X10  
   lcd_write_comm(0x06); //输入方式设置   
   lcd_write_comm(0x0f); //显示开关设置   
   lcd_write_comm(0x01); //清屏  
}

void lcd_write_comm(unsigned char comm)
{  
   lcd_busy_chek();
   
   LCD_CTRL_PORT&=~LCD_RW; //WRITE
   LCD_CTRL_PORT&=~LCD_RS; //RS=0
   
   LCD_DATA_PORT=comm;
   lcd_en_signal();
   
   LCD_CTRL_PORT^=LCD_RS; //CONVERSE RS
   LCD_CTRL_PORT^=LCD_RW; //WRITE
}

void lcd_posion(unsigned char x,unsigned char y)
{
    unsigned char address;
    if(y == 0) 
	   address = 0x80 + x; 
    else   
	   address = 0xc0 + x; 
    lcd_write_comm(address); 
}

void lcd_write_data(unsigned char data)
{
   lcd_busy_chek();
   
   LCD_CTRL_PORT&=~LCD_RW; //WRITE
   LCD_CTRL_PORT|=LCD_RS; //RS=0
   
   LCD_DATA_PORT = data;
   lcd_en_signal();
   
   LCD_CTRL_PORT^=LCD_RS; //CONVERSE RS
   LCD_CTRL_PORT^=LCD_RW; //WRITE
}

void lcd_write_str(unsigned char x,unsigned char y,unsigned char *p)  //写数据
{
   lcd_posion(x,y);
   
   while(*p)
   {
      lcd_write_data(*p);
	  p++;
   }

}

unsigned char lcd_read_char(unsigned char read_type)
{
    unsigned char temp;
	
	lcd_busy_chek();
	
    if(read_type==read_comm)   //read comm
	{
	   LCD_CTRL_PORT&=~LCD_RS;
	}
	else                      //read data
	{
	   LCD_CTRL_PORT|=LCD_RS;
	}
	LCD_CTRL_PORT|=LCD_RW; //read
	
	lcd_en_signal();
    temp=LCD_DATA_PIN;
	
	LCD_CTRL_PORT^=LCD_RW; //CONVERSE RW
	LCD_CTRL_PORT^=LCD_RS; //CONVERSE RS
	
	return temp;
}

void lcd_busy_chek(void)
{
   LCD_DATA_DDR  = 0X00;
   LCD_DATA_PORT = 0XFF;
   
   LCD_CTRL_PORT&=~LCD_RS;
   LCD_CTRL_PORT|=LCD_RW; //read
   
   //为什么这里换成函数lcd_en_signal()却不行???
   LCD_CTRL_PORT&=~LCD_EN;
   _delay_us(1);
   LCD_CTRL_PORT|=LCD_EN;
   _delay_us(1);
   LCD_CTRL_PORT&=~LCD_EN; 
   while( LCD_DATA_PIN&0X80 )
   {
      LCD_CTRL_PORT&=~LCD_EN;
      _delay_us(1);
      LCD_CTRL_PORT|=LCD_EN;
      _delay_us(1);
      LCD_CTRL_PORT&=~LCD_EN; 
   }
   /*
    lcd_en_signal();
    while( LCD_DATA_PIN&0X80 )
    {
       lcd_en_signal();
    }
   */
   //为什么这里换成函数lcd_en_signal()却不行???
   
   LCD_CTRL_PORT^=LCD_RW; //CONVERSE RW
   LCD_CTRL_PORT^=LCD_RS; //CONVERSE RS
   
   LCD_DATA_PORT = 0X00;
   LCD_DATA_DDR  = 0XFF;
}

void lcd_en_signal(void)
{   
   LCD_CTRL_PORT&=~LCD_EN;
   _delay_us(1);
   LCD_CTRL_PORT|=LCD_EN;
   _delay_us(1);
   LCD_CTRL_PORT&=~LCD_EN;   
}

main()
{
   PORTD=0X00;
   DDRD=0XFF;
   unsigned count=0;
   lcd_init();      
   
   while(1)
   {
       lcd_write_comm(0x01); //清屏 
       lcd_write_str(0,0,"dfgfhfgj");
       lcd_write_str(0,1,"shfghjhgkgk");
	   PORTD=1<<(count++%8);
       for(unsigned char i=0;i<200;i++)
	   _delay_ms(88);
	   
	   lcd_write_comm(0x01); //清屏 
	   lcd_write_str(0,0,"remember mydream");
       lcd_write_str(0,1,"I will be winner");
       PORTD=1<<(count++%8);
	   for(unsigned char j=0;j<200;j++)
	   _delay_ms(88); 
         
   }
}










 

(1)本站如需解压密码的资源,解压密码为:www.hymcu.com
(2)本站内所有资料仅限学习、交流,禁止用于任何商业用途!
(3)如果发现该资料不能下载或链接错误,请点击报告错误,谢谢!
(4)站内提供的资料部分来自网络以及注册用户自行上传,若侵犯了您的权益,敬请来信通知我们!
(5)若您的资料希望能与大家分享,我们愿意和您一起宣传!投稿请点击这里。
(6)本站不支持多线程下载。

返回

sitemap | 联系我们 | 广告服务 | 关于我们 | 版权信息 | 友情链接 | 网站地图 | 电话:15307733338 | 点击发消息给站长
CopyRight © 2007-2014 珩源科技all right Reserved Best view 1024*768 桂ICP备19004328号
地址:广西桂林市叠彩区站前路2号27栋 ┋总访问量  百度