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

0X00

  • 24c16读写驱动程序

    24c16读写驱动程序,//=-------------------------------------------------------------------------------/*模块调用:读数据:read(unsigned int address)写数据:write(unsigned int address,unsigned char dd)   dd为要写的 数据字节*///------------------------------------------------------------------------------ sbit sda=P3^0;sbit scl=P3^1; sbit a0=ACC^0;                  //定义ACC的位,利用ACC操作速度最快sbit a1=ACC^1;sbit a2=ACC^2;sbit a3=ACC^3;sbit a4=ACC^4;sbit a5=ACC^5;sbit a6=ACC^6;sbit a7=ACC^7; //------------------------------------------------------------------------------#pragma disablevoid s24(void)                 //起始函数{_nop_();    scl=0;     sda=1;    scl=1;    _nop_();    sda=0;    _nop_();    _nop_();    scl=0;     _nop_();    _nop_();    sda=1;} //------------------------------------------------------------------------------#pragma disablevoid p24(void)                 //停止函数{sda=0;    scl=1;    _nop_();    _nop_();    sda=1;} //-----------------------------------------------------------------------------#pragma disableunsigned char rd24(void) /////////////////从24c16读一字节数据{       ACC=0X00;sda=1;scl=1;a7=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a6=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a5=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a4=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a3=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a2=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a1=sda;_nop_();_nop_();_nop_();_nop_();scl=0;scl=1;a0=sda;_nop_();_nop_();_nop_();_nop_();scl=0;sda=1;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0; /// ///////////////24c16的一位回答位。return(ACC);}//------------------------------------------------------------------------------#pragma disablevoid wd24(unsigned char dd) ////////////////向24c16写一字节数据{      sda=1;ACC=dd;sda=a7;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a6;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a5;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a4;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a3;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a2;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a1;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=a0;scl=1;_nop_();_nop_();_nop_();_nop_();scl=0;sda=0;scl=1;//scl=0;(在下面程序中)}//---------------------------------------------------------------------------#pragma disableunsigned char read(unsigned int address){unsigned char dd;    s24();                        ////////////////////////开始条件    wd24(0xa0);                /////////////////////////写器件地址(写命令)     _nop_();_nop_();_nop_();_nop_();      scl=0;                        ///////////////////////////////////接收器件地址确认信号    wd24(address);                //////////////////////////// 写数据地址    _nop_();_nop_();_nop_();_nop_();    scl=0;s24();                             ///////////////////////////////////开始条件    wd24(0xa1);                 /////////////////////////////写器件地址(读命令)    scl=0;    dd=rd24();              //////////////////////////////////读 一字节    p24();                   ////////////////////////////////////停止条件    return(dd);}//------------------------------------------------------------------------------#pragma disablevoid write(unsigned int address,unsigned char dd){s24();                        /////////////////开始条件    wd24(0xa0);            ////////////////////////写器件地址;    scl=0;     wd24(address);              /////////////////////写数据地址    scl=0;    wd24(dd);                  //////////////////////////写dd数据    scl=0;    p24();                      /////////////////////////停止条件;  }          

    标签: 24c16 读写 驱动程序

    上传时间: 2013-11-18

    上传用户:墙角有棵树

  • 16 16点阵显示汉字原理及显示程序

    16 16点阵显示汉字原理及显示程序 #include "config.h" #define                DOTLED_LINE_PORT        PORTB #define                DOTLED_LINE_DDR                DDRB #define                DOTLED_LINE_PIN                PINB #define                DOTLED_LINE_SCKT        PB1 #define                DOTLED_LINE_SCKH        PB5 #define                DOTLED_LINE_SDA                PB3 #define                DOTLED_ROW_PORT                PORTC #define                DOTLED_ROW_DDR                DDRC #define                DOTLED_ROW_PIN                PINC #define                DOTLED_ROW_A0                PC0 #define                DOTLED_ROW_A1                PC1 #define                DOTLED_ROW_A2                PC2 #define                DOTLED_ROW_A3                PC3 #define                DOTLED_ROW_E                PC4 uint8 font[] = { /*--  调入了一幅图像:这是您新建的图像  --*/ /*--  宽度x高度=16x16  --*/ 0X00,0X00,0X00,0X00,0x08,0x38,0x18,0x44,0x08,0x44,0x08,0x04,0x08,0x08,0x08,0x10, 0x08,0x20,0x08,0x40,0x08,0x40,0x08,0x40,0x3E,0x7C,0X00,0X00,0X00,0X00,0X00,0X00 }; static void TransmitByte(uint8 byte); static void SelectRow(uint8 row); static void FlipLatchLine(void); static void TransmitByte(uint8 byte) {         uint8 i;                  for(i = 0 ; i < 8 ; i ++)         {                 if(byte & (1 << i))                 {                         DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SDA);                 }                 else                 {                         DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SDA);                 }                 //__delay_cycles(100);                 DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SCKH);                 //__delay_cycles(100);                 DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SCKH);                 //__delay_cycles(100);         } } static void SelectRow(uint8 row) {           //row -= 1;         row |= DOTLED_ROW_PIN & 0xe0;         DOTLED_ROW_PORT = row; } static void FlipLatchLine(void) {         DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SCKT);         DOTLED_LINE_PORT &= ~_BV(DOTLED_LINE_SCKT); } void InitDotLedPort(void) {         DOTLED_LINE_PORT &= ~(_BV(DOTLED_LINE_SCKT) | _BV(DOTLED_LINE_SCKH));         DOTLED_LINE_PORT |= _BV(DOTLED_LINE_SDA);         DOTLED_LINE_DDR |= _BV(DOTLED_LINE_SCKT) | _BV(DOTLED_LINE_SCKH) | _BV(DOTLED_LINE_SDA);                  DOTLED_ROW_PORT |= 0x1f;         DOTLED_ROW_PORT &= 0xf0;         DOTLED_ROW_DDR |= 0x1f; } void EnableRow(boolean IsEnable) {         if(IsEnable)         {                 DOTLED_ROW_PORT &= ~_BV(DOTLED_ROW_E);         }         else         {                 DOTLED_ROW_PORT |= _BV(DOTLED_ROW_E);         } } void PrintDotLed(uint8 * buffer) {         uint8 i , tmp;                  for(i = 0 ; i < 16 ; i ++)         {                 tmp = *buffer ++;                 TransmitByte(~tmp);                 tmp = *buffer ++;                 TransmitByte(~tmp);                 SelectRow(i);                 FlipLatchLine();         } } void main(void) {         InitDotLedPort();                  EnableRow(TRUE);                  while(1)         {                 PrintDotLed(font);                 __delay_cycles(5000);         }          } //---------------------------------------------------- config.h文件 #ifndef        _CONFIG_H #define        _CONFIG_H //#define                GCCAVR #define                CPU_CYCLES        7372800L #ifndef                GCCAVR #define                _BV(bit)        (1 << (bit)) #endif #define                MSB                0x80 #define                LSB                0x01 #define                FALSE                0 #define                TRUE                1 typedef                unsigned char        uint8; typedef                unsigned int        uint16; typedef                unsigned long        uint32; typedef                unsigned char        boolean; #include <ioavr.h> #include <inavr.h> #include "dotled.h" #endif //-----

    标签: 16 点阵显示 汉字 显示程序

    上传时间: 2013-11-17

    上传用户:mnacyf

  • 飞思卡尔智能车的舵机测试程序

    飞思卡尔智能车的舵机测试程序 #include <hidef.h>      /* common defines and macros */#include <MC9S12XS128.h>     /* derivative information */#pragma LINK_INFO DERIVATIVE "mc9s12xs128" void SetBusCLK_16M(void)             {       CLKSEL=0X00;        PLLCTL_PLLON=1;          //锁相环电路允许位    SYNR=0X00 | 0x01;        //SYNR=1    REFDV=0x80 | 0x01;          POSTDIV=0X00;            _asm(nop);              _asm(nop);    while(!(CRGFLG_LOCK==1));       CLKSEL_PLLSEL =1;          } void PWM_01(void) {     //舵机初始化   PWMCTL_CON01=1;    //0和1联合成16位PWM;    PWMCAE_CAE1=0;    //选择输出模式为左对齐输出模式    PWMCNT01 = 0;     //计数器清零;    PWMPOL_PPOL1=1;    //先输出高电平,计数到DTY时,反转电平    PWMPRCLK = 0X40;    //clockA 不分频,clockA=busclock=16MHz;CLK B 16分频:1Mhz     PWMSCLA = 0x08;    //对clock SA 16分频,pwm clock=clockA/16=1MHz;         PWMCLK_PCLK1 = 1;   //选择clock SA做时钟源    PWMPER01 = 20000;   //周期20ms; 50Hz;    PWMDTY01 = 1500;   //高电平时间为1.5ms;     PWME_PWME1 = 1;   

    标签: 飞思卡尔智能车 舵机 测试程序

    上传时间: 2013-11-04

    上传用户:狗日的日子

  • c8051f020 实时时钟模块程序 内含IIC模块程序/********************** SYSTEM CLOCK 8M********************************/

    c8051f020 实时时钟模块程序 内含IIC模块程序/********************** SYSTEM CLOCK 8M********************************/ extern unsigned char xdata currenttime[16]={0} extern unsigned char xdata settime[16]={ 0X00, // control regesiter 1 0X00, // control regesiter 2 0x01, //current second 0x19, //current minute 0x20, //current hour 0x29, //current data 0x04, //current week 0x07, //current month 0x05, //current year 0X00, // alarm value reset 0X00, // alarm value reset 0X00, // alarm value reset 0X00, // alarm value reset 0X00, // clk out disable 0X00, // close timer 0X00, } /*********************************************************************/ extern void Current_Time ( void ) extern void Set_Time ( void )

    标签: c8051f020 SYSTEM CLOCK IIC

    上传时间: 2015-06-30

    上传用户:edisonfather

  • C语言库函数速查[CHM文档]是一个很好的C语言函数查询器.属于CHM文档. iscntrl 原型:extern int iscntrl(int c) 用法:#include

    C语言库函数速查[CHM文档]是一个很好的C语言函数查询器.属于CHM文档. iscntrl 原型:extern int iscntrl(int c) 用法:#include <ctype.h> 功能:判断字符c是否为控制字符 说明:当c在0X00-0x1F之间或等于0x7F(DEL)时,返回非零值,否则返回零。

    标签: iscntrl CHM int include

    上传时间: 2015-08-15

    上传用户:lht618

  • DA 输出地址0x20400000 由于DAC0832要求输出锁存保持1uS左右 但CPU在读写(对应nGCS4)写信号最大只能到100ns左右 所以外面加了一个地址锁存74573

    DA 输出地址0x20400000 由于DAC0832要求输出锁存保持1uS左右 但CPU在读写(对应nGCS4)写信号最大只能到100ns左右 所以外面加了一个地址锁存74573,573锁存下降沿有效(现在是上升沿有效,也可用) 现在电阻不变的情况下,输出0X00,DA输出0V,输出0xff,DA输出1.7V左右

    标签: 0x20400000 74573 nGCS4 0832

    上传时间: 2014-01-04

    上传用户:gaojiao1999

  • CRC16算法的Java实现

    CRC16算法的Java实现,使用方法如下: CRC16 crc16 = new CRC16() byte[] b = new byte[] { // (byte) 0xF0,(byte)0xF0,(byte)0xF0,(byte)0x72 (byte) 0x2C, (byte) 0X00, (byte) 0xFF, (byte) 0xFE, (byte) 0xFE, (byte) 0x04, (byte) 0X00, (byte) 0X00, (byte) 0X00, (byte) 0X00 } for (int k = 0 k < b.length k++) { crc16.update(b[k]) } System.out.println(Integer.toHexString(crc16.getValue())) System.out.println(Integer.toHexString(b.length))

    标签: Java CRC 16 算法

    上传时间: 2014-12-19

    上传用户:ve3344

  • 51单片连tcs230的源程序

    51单片连tcs230的源程序,绝对原创,可以记忆颜色。 #define uchar unsigned char #include <reg52.h> #include<math.h> sbit S0=P1^7 sbit S1=P1^0 //端口定义 sbit S2=P1^1 sbit S3=P1^2 sbit OE=P1^3 sbit OUT=P3^4 //频率从TO口输入 sbit key0=P1^5 sbit LED=P1^6 sbit a=P3^0 sbit b=P3^1 uchar color //1:blue 2:green 3:red uchar T[4] //color timer uchar TH[4] uchar TL[4] uchar bizhi[4] void time1() interrupt 3 { TH[color]=TH0 TL[color]=TL0 T[color]=(TH[color]*0xff+TL[color]) TR0=0 //关定时器 TR1=0 TH1=0xB1 TL1=0xE0 //归0 TH0=0X00 TL0=0X00 //归0 }

    标签: tcs 230 源程序

    上传时间: 2016-11-26

    上传用户:秦莞尔w

  • CAN1.c and CAN2.c are a simple example of configuring a CAN network to transmit and receive data o

    CAN1.c and CAN2.c are a simple example of configuring a CAN network to transmit and receive data on a CAN network, and how to move information to and from CAN RAM message objects. Each C8051F040-TB CAN node is configured to send a message when it s P3.7 button is depressed/released, with a 0x11 to indicate the button is pushed, and 0X00 when released. Each node also has a message object configured to receive messages. The C8051 tests the received data and will turn on/off the target board s LED. When one target is loaded with CAN2.c and the other is loaded with CAN1.c, one target board s push-button will control the other target board s LED, establishing a simple control link via the CAN bus and can be observed directly on the target boards.

    标签: CAN configuring and transmit

    上传时间: 2013-12-10

    上传用户:weiwolkt

  • VB遥控播放器红外遥控解码 #include <regX52.h> #define c(x) (x*110592/120000) sbit Ir_Pin=P3^2 sb

    VB遥控播放器红外遥控解码 #include <regX52.h> #define c(x) (x*110592/120000) sbit Ir_Pin=P3^2 sbit beep=P2^1 //sbit RELAY=P2^0 #define INBUF_LEN 4 //数据长度 unsigned char inbuf1[INBUF_LEN]={ 0 , 0 , 0 , 0 } //发送缓冲区 unsigned char inbuf2[50] //接收缓冲区 unsigned char count3 void init_serialcomm( void ) { SCON = 0x50 //SCON: serail mode 1, 8-bit UART, enable ucvr T2CON=0x30 TH2=0X00 TL2=0X00 RCAP2H=0xFF RCAP2L=0xDC TR2=1 } //向串口发送一个字符 void send_char_com( unsigned char ch) { SBUF=ch while (TI== 0 ) TI= 0

    标签: include 110592 120000 define

    上传时间: 2013-12-21

    上传用户:yph853211