//芯片资料请到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