电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

L3G4200D51单片机IIC测试程序

L3G4200D51单片机IIC测试程序_第1页
1/11
L3G4200D51单片机IIC测试程序_第2页
2/11
L3G4200D51单片机IIC测试程序_第3页
3/11
//这是L3G4200D 51 单片机IIC 测试程序 //这是1602 头文件 保存为 1602.h #define DataPort P0 //LCD1602 数据端口 sbit LCD_RS=P2^4; //LCD1602 命令端口 sbit LCD_RW=P2^5; //LCD1602 命令端口 sbit LCD_EN=P2^6; //LCD1602 命令端口 #include #define uchar unsigned char void WaitForEnable(void) { DataPort=0xff; LCD_RS=0; LCD_RW=1; _nop_(); LCD_EN=1; _nop_(); _nop_(); while(DataPort&0x80); LCD_EN=0; } void WriteCommandLCD(uchar CMD,uchar Attribc) { if(Attribc) WaitForEnable(); LCD_RS=0; LCD_RW=0; _nop_(); DataPort=CMD; _nop_(); LCD_EN=1; _nop_(); _nop_(); LCD_EN=0; } void WriteDataLCD(uchar dataW) { WaitForEnable(); LCD_RS=1; LCD_RW=0; _nop_(); DataPort=dataW; _nop_(); LCD_EN=1; _nop_(); _nop_(); LCD_EN=0; } void InitLcd() { WriteCommandLCD(0x38,1); WriteCommandLCD(0x08,1); WriteCommandLCD(0x01,1); WriteCommandLCD(0x06,1); WriteCommandLCD(0x0c,1); } void DisplayOneChar(uchar X,uchar Y,uchar DData) { Y&=1; X&=15; if(Y) X|=0x40; X|=0x80; WriteCommandLCD(X,0); WriteDataLCD(DData); } //下面是主程序部分 //*************************************** // L3G4200D 三轴陀螺仪 IIC 测试程序 // 使用单片机 STC89C51 // 晶振:11.0592M // 显示:LCD1602 // 编译环境 Keil uVision2 // 参考宏晶网站 24c04 通信程序 // 时间:2011 年 3 月 1 日 //**************************************** #include #include "1602.h" #include #include #include #define uchar unsigned char #define uint unsigned int sbit SCL=P1^0 ; //IIC 时钟引脚定义 sbit SDA=P1^1 ; //IIC 数据引脚定义 //******************** #define WHO_AM_I 0x0F #define CTRL_REG1 0x20 // 0010 0000 #define CTRL_REG2 0x21 #define CTRL_REG3 0x22 #define CTRL_REG4 0x23 #define CTRL_REG5 0x24 #define OUT_X_L 0x28 #define OUT_X_H 0x29 #define OUT_Y_L 0x2A #define OUT_Y_H 0x2B #define OUT_Z_L 0x2C #define OUT_Z_H 0x2D #define ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

L3G4200D51单片机IIC测试程序

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部