虫虫首页|资源下载|资源专辑|精品软件
登录|注册

SystemError

  • #include "intrins.h" unsigned char SystemError sbit SCL= P1^6 //定义串行时钟线所在口 使用时根据自己的需要 sbit SDA=

    #include "intrins.h" unsigned char SystemError sbit SCL= P1^6 //定义串行时钟线所在口 使用时根据自己的需要 sbit SDA= P1^7 //定义串行数据线所在口 使用时根据自己的需要 #define SomeNOP() {_nop_() _nop_() _nop_() _nop_() }

    标签: sbit SystemError unsigned include

    上传时间: 2015-08-30

    上传用户:rocketrevenge

  • I2C总线驱动程序

    1 /**————————————————————2 〖说明〗I2C总线驱动程序(用两个普通IO模拟I2C总线)3 包括100Khz(T=10us)的标准模式(慢速模式)选择,4 和400Khz(T=2.5us)的快速模式选择,5 默认11.0592Mhz的晶振。6 〖文件〗PCF8563T.C ﹫2001/11/2 77 〖作者〗龙啸九天 c51@yeah.net http://www.c51bbs.co /8 〖修改〗修改建议请到论坛公布 http://www.c51bbs.co m9 〖版本〗V1.00A Build 080310 —————————————————————*/1112 #ifndef SDA13 #define SDA P0_014 #define SCL P0_115 #endif1617 extern uchar SystemError;1819 #define uchar unsigned char20 #define uint unsigned int21 #define Byte unsigned char22 #define Word unsigned int23 #define bool bit24 #define true 125 #define false 02627 #define SomeNOP(); _nop_();_nop_();_nop_();_nop_();2829 /**--------------------------------------------------------------------------------30 调用方式:void I2CStart(void) ﹫2001/07/0 431 函数说明:私有函数,I2C专用32 ---------------------------------------------------------------------------------*/33 void I2CStart(void)34 {35 EA=0;36 SDA=1; SCL=1; SomeNOP();//INI37 SDA=0; SomeNOP(); //START38 SCL=0;39 }4041 /**--------------------------------------------------------------------------------42 调用方式:void I2CStop(void) ﹫2001/07/0 443 函数说明:私有函数,I2C专用44 ---------------------------------------------------------------------------------*/45 void I2CStop(void)46 {47 SCL=0; SDA=0; SomeNOP(); //INI48 SCL=1; SomeNOP(); SDA=1; //STOP49 EA=1;50 }5152 /**--------------------------------------------------------------------------------53 调用方式:bit I2CAck(void) ﹫2001/07/0 454 函数说明:私有函数,I2C专用,等待从器件接收方的应答55 ---------------------------------------------------------------------------------*/56 bool WaitAck(void)57 {58 uchar errtime=255;//因故障接收方无ACK,超时值为255。59 SDA=1;SomeNOP();60 SCL=1;SomeNOP();61 while(SDA) {errtime--; if (!errtime) {I2CStop();SystemError=0x11;return false;}}62 SCL=0;63 return true;

    标签: I2C 总线 驱动程序

    上传时间: 2014-04-11

    上传用户:xg262122

  • unsigned char WriteInData(unsigned char Address,unsigned char DataByte) { unsigned char mark WREN

    unsigned char WriteInData(unsigned char Address,unsigned char DataByte) { unsigned char mark WREN() Write_Byte(0x02) Write_Byte(Address) Write_Byte(DataByte) //NOP() X25_cs=1 lag(3000) mark=Read_Byte(Address) if(DataByte==mark) SystemError=0 if(mark!=DataByte) SystemError=1 // return(SystemError) } //虽然是一读一写,但是其中暗藏杀机,让人很难调通。一定注意接口的位置!呵呵!不信你就按普通的SPI程序方法写写试试!

    标签: unsigned char WriteInData DataByte

    上传时间: 2016-12-14

    上传用户:invtnewer