//芯片資料請到www.elecfans.com查找 //DS1820 C51 子程序//這里以11.0592M晶體為例,不同的晶體速度可能需要調整延時的時間//sbit DQ =P2^1;//根據實際情況定義端口 typedef unsigned char byte;typedef unsigned int word; //延時void delay(word useconds){ for(;useconds>0;useconds--);} //復位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 總線上讀取一個字節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 總線上寫一個字節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;}
上傳時間: 2013-11-03
上傳用戶:hongmo
T2作為波特率控制UART_RXD 是硬中斷0或1口,如果能進入中斷,說明該線有一個起始位產生,進入中斷后調用下面的接收程序。退出硬中斷之前還需要將硬中斷標志重新復位。UART_TXD 是任何其它IO即可。UART_SEND: PUSH IE PUSH DPH PUSH DPL PUSH PSW PUSH 00H PUSH ACC CLR EA SETB UART_TXD ;START BIT MOV R0,A CLR TR2 ;TR2置1,計數器2啟動,時間計數啟動。 MOV A,RCAP2L;計數器2重新裝載值 MOV TL2,A ;置計數器2初值 ;T2需要重新裝載 MOV A,DPH MOV A,RCAP2H MOV TH2,A MOV A,R0 SETB TR2 ;TR2置1,計數器 JNB TF2,$ CLR TF2 JNB TF2,$ CLR TF2
上傳時間: 2014-01-12
上傳用戶:二十八號
#include <at24c01a.h>/*************************************************向24C01A寫入一個字節輸入:E2ROM地址,字節數據******************************************************/void write24c01a(uchar uadd_1,uchar udata_1){sendbyte=0xa0;start();send(sendbyte);if (!ack())continue;send(uadd_1);if (!ack())continue;send(udata_1)if (!ack())continue;stop();}/**********************************發送開始*****************************************/void start(void){a_scl=1;a_sda=1;a_sda=0;a_scl=0;a_scl=1;}/********************************************發送停止*******************************************/void stop(void){a_scl=0;a_sda=0;a_scl=1;a_sda=1;} /*********************************************發送反饋************************************************/bit ack(void){int a_acka_scl=0;a_scl=0;a_scl=0;a_scl=1;a_ack=a_sda;a_scl=0;return(a_ack)}/**************************************發送無反饋********************************************/bit noack(void){int a_ack;a_scl=1;a_scl=1;a_scl=0;}/*******************************************發送****************************************************/void send(uchar undata){uchar i;sendbyte=undatafor(i=8;i>0;i--){a_sda=sendbyte7;a_scl=0;a_scl=1;sendbyte=sendbyte<<1}}/********************************************接受****************************************************/ void receive(void){int i;uchar data;for(i=8;i>0;i--){ a_scl=1;receivebyte7=a_sda;a_scl=0;receivebyte=receivebyte>>1}receivedata=receivebyte;}/********************************************向 24c01a讀一個字節;輸入:EEROM地址;輸出:EEROM數據;********************************************/void read24c01a(uchar counter){receivebyte=0xa1;start();send(receivebyte);if (!ack())continue;send(counter);if (!ack())continue;receive()noack();stop();}
上傳時間: 2013-12-23
上傳用戶:wxhwjf
紅外遙控接收;=================================================;; zsMCU51實驗板配套學習例程;; 中山單片機學習網 智佳科技;; 作者:逸風 QQ:105558851;; http://www.zsmcu.com; E-mail:info@zsmcu.com;=================================================ORG 0000HLJMP START;轉入主程序ORG 0010HSTART:MAIN:JNB P2.2,IRLJMP MAIN;以下為進入P3.2腳外部中斷子程序,也就是解碼程序IR:MOV R6,#9SB:ACALL DELAY882 ;調用882微秒延時子程序JB P2.2,EXIT ;延時882微秒后判斷P3.2腳是否出現高電平如果有就退出解碼程序DJNZ R6, SB ;重復10次,目的是檢測在8820微秒內如果出現高電平就退出解碼程序;以上完成對遙控信號的9000微秒的初始低電平信號的識別。JNB P2.2, $ ;等待高電平避開9毫秒低電平引導脈沖ACALL DELAY2400JNB P2.2,IR_Rp ;ACALL DELAY2400 ;延時4.74毫秒避開4.5毫秒的結果碼MOV R1,#1AH ;設定1AH為起始RAM區MOV R2,#4PP:MOV R3,#8JJJJ:JNB P2.2,$ ;等待地址碼第一位的高電平信號LCALL DELAY882 ;高電平開始后用882微秒的時間尺去判斷信號此時的高低電平狀態MOV C,P2.2 ;將P3.2引腳此時的電平狀態0或1存入C中 JNC UUU ;如果為0就跳轉到UUULCALL DELAY1000UUU:MOV A,@R1 ;將R1中地址的給ARRC A ;將C中的值0或1移入A中的最低位MOV @R1,A ;將A中的數暫時存放在R1中DJNZ R3,JJJJ ;接收地址碼的高8位INC R1 ;對R1中的值加1,換下一個RAMDJNZ R2,PP ;接收完16位地址碼和8位數據碼和8位數據,存放在1AH/1BH/1CH/1DH的RAM中MOV P1,1DH ;將按鍵的鍵值通過P1口的8個LED顯示出來!CLR P2.3 ;蜂鳴器鳴響-嘀嘀嘀-的聲音,表示解碼成功LCALL DELAY2400LCALL DELAY2400LCALL DELAY2400SETB P2.3;蜂鳴器停止LJMP MAINIR_Rp:LJMP MAINEXIT:LJMP MAIN ;退出解碼子程序;=============================882DELAY882: ;1.085x ((202x4)+5)=882MOV R7,#202DELAY882_A:NOPNOPDJNZ R7,DELAY882_ARET;=============================1000DELAY1000: ;1.085x ((229x4)+5)=999.285MOV R7,#229DELAY1000_A:NOPNOPDJNZ R7,DELAY1000_ARET;=============================2400
上傳時間: 2013-11-01
上傳用戶:2525775
系統start-up 定時器• 為了讓振蕩器能夠穩定起振所需要的延時時間。• 其時間為1024 個振蕩器振蕩周期。制程和溫度漂移• 因RC 振蕩器的頻率與內建振蕩電容值有關,而此電容值與制程參數有關,所以不同的MCU 會表現出不一致性。在固定電壓和溫度下,振蕩頻率漂移范圍約±25%。• 對于同一顆MCU(與制程漂移無關),其振蕩頻率會對工作電壓和工作溫度產生漂移。其對工作電壓和工作溫度所產生的漂移,可參考HOLTEK 網站上提供的相關資料。EMI/EMS(EMC)注意事項• ROSC 位置應盡量接近OSC1 引腳,其至OSC1 的連線應最短。• CS 可以提高振蕩器的抗干擾能力,其與MCU OSC1 和GND 的連線應最短。• RPU 在確定系統頻率之后,量產時建議不要接,因為其fSYS/4 頻率輸出會干擾到OSC1
上傳時間: 2014-01-20
上傳用戶:yyyyyyyyyy
用單片機配置FPGA—PLD設計技巧 Configuration/Program Method for Altera Device Configure the FLEX Device You can use any Micro-Controller to configure the FLEX device–the main idea is clocking in ONE BITof configuration data per CLOCK–start from the BIT 0The total Configuration time–e.g. 10K10 need 15K byte configuration file•calculation equation–10K10* 1.5= 15Kbyte–configuration time for the file itself•15*1024*8*clock = 122,880Clock•assume the CLOCK is 4MHz•122,880*1/4Mhz=30.72msec
上傳時間: 2013-10-09
上傳用戶:a67818601
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;
上傳時間: 2014-04-11
上傳用戶:xg262122
The Xilinx Zynq-7000 Extensible Processing Platform (EPP) redefines the possibilities for embedded systems, giving system and software architects and developers a flexible platform to launch their new solutions and traditional ASIC and ASSP users an alternative that aligns with today’s programmable imperative. The new class of product elegantly combines an industrystandard ARMprocessor-based system with Xilinx 28nm programmable logic—in a single device. The processor boots first, prior to configuration of the programmable logic. This, along with a streamlined workflow, saves time and effort and lets software developers and hardware designers start development simultaneously.
上傳時間: 2013-11-01
上傳用戶:dingdingcandy
The CodeWarrior Development Suite provides access and technical support to amultitude of CodeWarrior products. In this quick start guide, Section 1 explains howto register your CodeWarrior Development Suite. Section 2 explains how to activateand install one of your products. Section 3 describes what you are entitled to withthe purchase of your CodeWarrior Development Suite, and Section 4 discusses theavailable purchase options. Section 5 describes the benefits of maintaining a currenttechnical support contract, and Section 6 tells you how to access support.
標簽: CodeWarrior 開發套件
上傳時間: 2014-03-02
上傳用戶:784533221
提出了一種以ARM微處理器為控制核心的遠程無線視頻監控終端的設計方案,其監控終端的硬件設計包括視頻采集處理、中央管理控制、無線傳輸3個模塊。并給出了監控終端的軟件開發平臺和開發模式的系統啟動代碼、嵌入式Linux系統移植以及驅動程序和應用程序。測試結果表明,該監控終端設計方案合理、有效,基本滿足監控需求。 Abstract: A remote wireless video monitoring terminal design, which uses ARM microprocessor as its core control, is proposed in this paper.The hardware design of monitoring terminal system is composed of the video acquisition and processing module, the central management and control module, wireless transmission module.Meanwhile the monitoring terminal-s software development platform and development patterns are designed. Also the design of the system-s start codes, embedded Linux system-s transplantation process, driver and the corresponding applications are given. The results showed that the monitoring terminal design is reasonable, effective, basically meet monitoring requirements.
上傳時間: 2013-11-13
上傳用戶:wanqunsheng