亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

CHar

  • DS1820 C51 子程序 (一線數(shù)據(jù)傳輸)

    //芯片資料請到www.elecfans.com查找 //DS1820 C51 子程序//這里以11.0592M晶體為例,不同的晶體速度可能需要調(diào)整延時(shí)的時(shí)間//sbit DQ =P2^1;//根據(jù)實(shí)際情況定義端口 typedef unsigned CHar byte;typedef unsigned int  word; //延時(shí)void delay(word useconds){  for(;useconds>0;useconds--);} //復(fù)位byte ow_reset(void){  byte presence;  DQ = 0; //pull DQ line low  delay(29); // leave it low for 480us  DQ = 1; // allow line to return high  delay(3); // wait for presence  presence = DQ; // get presence signal  delay(25); // wait for end of timeslot  return(presence); // presence signal returned}     // 0=presence, 1 = no part //從 1-wire 總線上讀取一個(gè)字節(jié)byte read_byte(void){  byte i;  byte value = 0;  for (i=8;i>0;i--)  {    value>>=1;    DQ = 0; // pull DQ low to start timeslot    DQ = 1; // then return high    delay(1);  //for (i=0; i<3; i++);     if(DQ)value|=0x80;    delay(6); // wait for rest of timeslot  }  return(value);} //向 1-WIRE 總線上寫一個(gè)字節(jié)void write_byte(CHar val){  byte i;  for (i=8; i>0; i--) // writes byte, one bit at a time  {    DQ = 0; // pull DQ low to start timeslot    DQ = val&0x01;    delay(5); // hold value for remainder of timeslot    DQ = 1;    val=val/2;  }  delay(5);} //讀取溫度CHar Read_Temperature(void){  union{    byte c[2];    int x;  }temp;   ow_reset();  write_byte(0xCC); // Skip ROM  write_byte(0xBE); // Read Scratch Pad  temp.c[1]=read_byte();  temp.c[0]=read_byte();  ow_reset();  write_byte(0xCC); //Skip ROM  write_byte(0x44); // Start Conversion  return temp.x/2;}

    標(biāo)簽: 1820 C51 DS 程序

    上傳時(shí)間: 2013-11-03

    上傳用戶:hongmo

  • 用C51寫的普通拼音輸入法源程序代碼

    用C51寫的普通拼音輸入法源程序代碼:原作使用了一個(gè)二維數(shù)組用以查表,我認(rèn)為這樣比較的浪費(fèi)空間,而且每個(gè)字表的索引地址要手工輸入,效率不高。所以我用結(jié)構(gòu)體將其改寫了一下。就是大家現(xiàn)在看到的這個(gè)。  因?yàn)榇a比較的大,共有6,000多漢字,這樣就得要12,000 byte來存放GB內(nèi)碼,所以也是沒辦法的.編譯結(jié)果約為3000h,因?yàn)榇蟛糠质撬饕恚a優(yōu)化幾乎無效。    在Keil C里仿真芯片選用的是華邦的W77E58,它有32k ROM, 256B on-chip RAM, 1K on-chip SRAM (用DPTR1指針尋址,相當(dāng)于有1K的片上xdata)。條件有限,沒有上片試驗(yàn),仿真而已。  打算將其移植到AVR上,但CodeAVRC與IAR EC++在結(jié)構(gòu)體、指針的定義使用上似乎與C51不太一樣,現(xiàn)在還未搞定。還希望在這方面有經(jīng)驗(yàn)的網(wǎng)友能給予指導(dǎo)。 #include<stdio.h> CHar * py_ime(CHar *); void main(void){ while(1)    {     CHar input_string[]="yI";     xdata CHar chinese_string[255];     sprintf(chinese_string,"%s",py_ime(input_string));    }}

    標(biāo)簽: C51 拼音輸入法 代碼 源程序

    上傳時(shí)間: 2013-10-30

    上傳用戶:cainaifa

  • 采用18b20芯片的溫度測量C51源程序

    #include <reg51.h>#include<intrins.h> #define   BUSY1    (DQ1==0) sbit      DQ1    =  P0^4; unsigned CHar idata TMP; unsigned CHar idata TMP_d; unsigned CHar f; void wr_ds18_1(CHar dat);unsigned CHar rd_ds18_1(); /***************延時(shí)程序,單位us,大于10us*************/void time_delay(unsigned CHar time){   time=time-10;  time=time/6;  while(time!=0)time--;} /*****************************************************//*                reset ds18b20                      *//*****************************************************/void ds_reset_1(void){  unsigned CHar idata count=0;    DQ1=0;   time_delay(240); time_delay(240);  DQ1=1;  return;}

    標(biāo)簽: 18b20 C51 芯片 溫度測量

    上傳時(shí)間: 2013-10-29

    上傳用戶:sssnaxie

  • 24c16讀寫驅(qū)動(dòng)程序

    24c16讀寫驅(qū)動(dòng)程序,//=-------------------------------------------------------------------------------/*模塊調(diào)用:讀數(shù)據(jù):read(unsigned int address)寫數(shù)據(jù):write(unsigned int address,unsigned CHar dd)   dd為要寫的 數(shù)據(jù)字節(jié)*///------------------------------------------------------------------------------ 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)                 //起始函數(shù){_nop_();    scl=0;     sda=1;    scl=1;    _nop_();    sda=0;    _nop_();    _nop_();    scl=0;     _nop_();    _nop_();    sda=1;} //------------------------------------------------------------------------------#pragma disablevoid p24(void)                 //停止函數(shù){sda=0;    scl=1;    _nop_();    _nop_();    sda=1;} //-----------------------------------------------------------------------------#pragma disableunsigned CHar rd24(void) /////////////////從24c16讀一字節(jié)數(shù)據(jù){       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寫一字節(jié)數(shù)據(jù){      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;                        ///////////////////////////////////接收器件地址確認(rèn)信號(hào)    wd24(address);                //////////////////////////// 寫數(shù)據(jù)地址    _nop_();_nop_();_nop_();_nop_();    scl=0;s24();                             ///////////////////////////////////開始條件    wd24(0xa1);                 /////////////////////////////寫器件地址(讀命令)    scl=0;    dd=rd24();              //////////////////////////////////讀 一字節(jié)    p24();                   ////////////////////////////////////停止條件    return(dd);}//------------------------------------------------------------------------------#pragma disablevoid write(unsigned int address,unsigned CHar dd){s24();                        /////////////////開始條件    wd24(0xa0);            ////////////////////////寫器件地址;    scl=0;     wd24(address);              /////////////////////寫數(shù)據(jù)地址    scl=0;    wd24(dd);                  //////////////////////////寫dd數(shù)據(jù)    scl=0;    p24();                      /////////////////////////停止條件;  }          

    標(biāo)簽: 24c16 讀寫 驅(qū)動(dòng)程序

    上傳時(shí)間: 2013-11-18

    上傳用戶:墻角有棵樹

  • RD系列微型打印機(jī)打印實(shí)例

    C51控制并口打印機(jī)實(shí)例:/* 沈陽新榮達(dá)電子 *//* 2004-12-7 */#include <reg52.h>#define uCHar unsigned CHar#define uint unsigned int#define data_8 P0sbit BUSY = P1^2; //打印機(jī) BUSY 接P1.2sbit STB = P1^0; //打印機(jī) STB 接P1.0void print(uCHar j) //打印子程序{ uCHar i;while(BUSY){}; //BUSY=1,打印機(jī)忙,等待BUSY 為0 再發(fā)數(shù)data_8=j;STB=0;i++;i--;STB=1; //給出數(shù)據(jù)鎖存時(shí)鐘BUSY=1;}void main(void){BUSY = 1; //忙信號(hào)置高STB = 1; //選通信號(hào)置高print(0x1b); //打印機(jī)初始化命令print(0x38);print(0x04);for(;;){print(0xd0); //發(fā)送漢字內(nèi)碼“新榮達(dá)”print(0xc2);print(0xc8);print(0xd9);print(0xb4);print(0xef);print(0x0d); //換行}}

    標(biāo)簽: 微型打印機(jī) 打印

    上傳時(shí)間: 2013-11-13

    上傳用戶:lwq11

  • 微型打印機(jī)的C語言源程序

    微型打印機(jī)的C語言源程序:微型打印機(jī)的C51源程序#define uCHar unsigned CHar#define uint unsigned int#include <reg52.h>#include <stdio.h>#include <absacc.h>#include <math.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#define PIN XBYTE[0x8000]#define POUT XBYTE[0x9000]sbit PRINTSTB =P1^6;sbit DOG=P1^7;bdata CHar pin&#118alue;sbit PRINTBUSY=pin&#118alue^7;sbit PRINTSEL =pin&#118alue^6;sbit PRINTERR =pin&#118alue^5;sbit PRINTACK =pin&#118alue^4;  void PrintString(uCHar *String1,uCHar *String2);void initprint(void);void print(uCHar a);  void initprint(void) //打印機(jī)初始化子程序 {  pin&#118alue=PIN;  if((PRINTSEL==1)&&(PRINTERR==1))  {    print(0x1b); print(0x40); print(0x1b); print(0x38); print(0x4);  }}void print(uCHar a) //打印字符a{  pin&#118alue=PIN;  if((PRINTSEL==0)||(PRINTERR==0)) return;  for(;;) {    DOG=~DOG;    pin&#118alue=PIN;    if(PRINTBUSY==0) break;  }  DOG=~DOG;  POUT=a;  PRINTSTB=1;  PRINTSTB=1;  PRINTSTB=1;  PRINTSTB=1;  PRINTSTB=0;  PRINTSTB=0;  PRINTSTB=0;  PRINTSTB=0;  PRINTSTB=1;}void PrintString(uCHar *String) //打印字符串后回車{  uCHar CH;  for (;;) {   DOG=~DOG;   CH=*String;   if (CH==0) { print(0x0d); break; }   print(CH);   String++;  }  initprint();}

    標(biāo)簽: 微型打印機(jī) C語言 源程序

    上傳時(shí)間: 2013-10-18

    上傳用戶:hasan2015

  • LC7461遙控解碼子程序源代碼

    //遙控解碼子程序,LC7461,用戶碼為11C//external interrupt0void isr_4(){  unsigned CHar r_count;//定義解碼的個(gè)數(shù) unsigned long use_data=0;//定義16位的用戶碼,只用到13位 unsigned long use_code=0;//定義16位的用戶反碼,只用到13位 unsigned long data=0;//定義16位數(shù)據(jù)碼,包括8位數(shù)據(jù)碼和反碼 unsigned CHar data_h=0;//數(shù)據(jù)反碼 unsigned CHar data_l=0;//數(shù)據(jù)碼 _clrwdt();// _delay(7000);//7461解碼,延時(shí)7000// _delay(7000);//7461解碼,延時(shí)7000//_delay(7000);//7461解碼,延時(shí)7000 if(remote==1)  goto error; while(remote==0);//wait to high //_delay(9744);count_delay=0; while(count_delay<143); if(remote==1)  goto error;     /////用戶碼解碼use_data//////////add//////////////////////////     for(r_count=13;r_count>0;r_count--)  {  while(remote==0);//wait to high  count_delay=0;     while(count_delay<24);//_delay(1680);  _c=remote;  if(_c==1)   {   _lrrc(&use_data);   count_delay=0;         while(count_delay<32);//_delay(2200);//wait to low   }  else   _lrrc(&use_data);  }  _nop(); //if(remote==1)  //_delay(1680);//wait to low while(remote==1);//wait to low     _nop();     ////////用戶碼解碼finish/////////add/////////add////////     /////用戶碼反碼解碼use_code//////////add//////////////////////////     for(r_count=13;r_count>0;r_count--)  {  while(remote==0);//wait to high  count_delay=0;         while(count_delay<24);//_delay(1680);  _c=remote;  if(_c==1)   {   _lrrc(&use_code);   count_delay=0;         while(count_delay<32);//_delay(2200);//wait to low   }  else   _lrrc(&use_code);  } _nop(); //if(remote==1) // _delay(1680);//wait to low while(remote==1);//wait to low     _nop();     ////////用戶碼反碼解碼finish/////////add/////////add////////     ////數(shù)據(jù)碼解碼開始////data_l為用戶碼,data_h為數(shù)據(jù)碼反碼//////////// for(r_count=16;r_count>0;r_count--)  {  while(remote==0);//wait to high  count_delay=0;         while(count_delay<24);//_delay(1680);  _c=remote;  if(_c==1)   {   _lrrc(&data);   count_delay=0;         while(count_delay<32);//_delay(2200);//wait to low   }  else   _lrrc(&data);  } ////數(shù)據(jù)碼解碼結(jié)束//////////////////////////////////////////////// data_l=data; data_h=data>>8; ///用戶碼////// use_data>>=3; use_code>>=3; use_code=~use_code; //////// ////如果用戶碼等與0x11c并且數(shù)據(jù)碼和數(shù)據(jù)反碼都校驗(yàn)一致,解碼成功 //if((~data_h==data_l)&&use_data==0x11c)//使用用戶碼 //跳過用戶碼 if(~data_h==data_l)//如果數(shù)據(jù)碼和數(shù)據(jù)反碼(取反后)相等,解碼正確  {  _nop();  r_data=data_l;//r_data為解出的最終數(shù)據(jù)碼  } //否則解碼不成功 _nop(); _nop();error:  //r_data=nocode; _nop();    _nop(); _nop();}

    標(biāo)簽: 7461 LC 遙控 解碼

    上傳時(shí)間: 2014-03-27

    上傳用戶:shenlan

  • 16 16點(diǎn)陣顯示漢字原理及顯示程序

    16 16點(diǎn)陣顯示漢字原理及顯示程序 #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[] = { /*--  調(diào)入了一幅圖像:這是您新建的圖像  --*/ /*--  寬度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 //-----

    標(biāo)簽: 16 點(diǎn)陣顯示 漢字 顯示程序

    上傳時(shí)間: 2013-11-18

    上傳用戶:mnacyf

  • 51單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)(含電路圖和C語言源程序代碼)

    51單片機(jī)驅(qū)動(dòng)步進(jìn)電機(jī)(含電路圖和源程序代碼) 源程序:stepper.c stepper.hex /* * STEPPER.C * sweeping stepper's rotor cw and cww 400 steps * Copyright (c) 1999 by W.Sirichote */ #i nclude c:\mc5151io.h /* include i/o header file */ #i nclude c:\mc5151reg.h register unsigned CHar j,flag1,temp; register unsigned int cw_n,ccw_n; unsigned CHar step[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90} #define n 400 /* flag1 mask byte 0x01 run cw() 0x02 run ccw() */

    標(biāo)簽: 51單片機(jī) 驅(qū)動(dòng) 步進(jìn)電機(jī) C語言

    上傳時(shí)間: 2013-11-09

    上傳用戶:釣鰲牧馬

  • I2C總線驅(qū)動(dòng)程序

    1 /**————————————————————2 〖說明〗I2C總線驅(qū)動(dòng)程序(用兩個(gè)普通IO模擬I2C總線)3 包括100Khz(T=10us)的標(biāo)準(zhǔn)模式(慢速模式)選擇,4 和400Khz(T=2.5us)的快速模式選擇,5 默認(rèn)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 調(diào)用方式:void I2CStart(void) ﹫2001/07/0 431 函數(shù)說明:私有函數(shù),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 調(diào)用方式:void I2CStop(void) ﹫2001/07/0 443 函數(shù)說明:私有函數(shù),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 調(diào)用方式:bit I2CAck(void) ﹫2001/07/0 454 函數(shù)說明:私有函數(shù),I2C專用,等待從器件接收方的應(yīng)答55 ---------------------------------------------------------------------------------*/56 bool WaitAck(void)57 {58 uCHar errtime=255;//因故障接收方無ACK,超時(shí)值為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;

    標(biāo)簽: I2C 總線 驅(qū)動(dòng)程序

    上傳時(shí)間: 2014-04-11

    上傳用戶:xg262122

主站蜘蛛池模板: 龙州县| 灌阳县| 稻城县| 安义县| 阿拉尔市| 湖州市| 阜康市| 承德县| 宝清县| 正镶白旗| 监利县| 巴中市| 大冶市| 格尔木市| 诏安县| 治多县| 昌乐县| 蒙城县| 平安县| 宜兴市| 股票| 疏勒县| 延安市| 景宁| 台北县| 改则县| 定边县| 东辽县| 融水| 大足县| 航空| 平邑县| 雅江县| 大宁县| 西华县| 略阳县| 武川县| 清苑县| 大足县| 海兴县| 嘉祥县|