This application note demonstrates how to write an Inter Integrated Circuit bus driver (I2C) for the XA-S3 16-bitMicrocontroller from Philips Semiconductors.Not only the driver software is given. This note also contains a set of (example) interface routines and a smalldemo application program. All together it offers the user a quick start in writing a complete I2C system applicationwith the PXAS3x.The driver routines support interrupt driven single master transfers. Furthermore, the routines are suitable foruse in conjunction with real time operating systems.
上传时间: 2013-11-02
上传用户:zw380105939
I2C interface, is a very powerful tool for system designers. Theintegrated protocols allow systems to be completely software defined.Software development time of different products can be reduced byassembling a library of reusable software modules. In addition, themultimaster capability allows rapid testing and alignment ofend-products via external connections to an assembly-line computer.The mask programmable 87LPC76X and its EPROM version, the87LPC76X, can operate as a master or a slave device on the I2Csmall area network. In addition to the efficient interface to thededicated function ICs in the I2C family, the on-board interfacefacilities I/O and RAM expansion, access to EEPROM andprocessor-to-processor communications.
标签: microcontro Using 76X LPC
上传时间: 2013-12-30
上传用户:Artemis
//芯片资料请到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
#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(); /***************延时程序,单位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;}
上传时间: 2013-10-29
上传用户:sssnaxie
PLC 以 其 可靠性高、抗干扰能力强、配套齐全、功能完善、适应性强等特点,广泛应用于各种控制领域。PLC作为通用工业控制计算机,是面向工矿企业的工控设备,使用梯形图符号进行编程,与继电器电路相当接近,被广大工程技术人员接受。但是在实际应用中,如何编程能够提高PLC程序运行速度是一个值得我们思考研究的问题。1 PLC工作原理PLC 与 计 算机的工作原理基本相同,即在系统程序的管理下,通过运行应用程序完成用户任务。但两者的工作方式有所不同。计算机一般采用等待命令的工作方式,而PLC在确定了工作任务并装人了专用程序后成为一种专用机,它采用循环扫描工作方式,系统工作任务管理及应用程序执行都是用循环扫描方式完成的。PLC 有 两 种基本的工作状态,即运行(RUN)与停止(STOP)状态。在这两种状态下,PLC的扫描过程及所要完成的任务是不尽相同的,如图1所示。 PLC在RUN工作状态时,执行一次扫描操作所的时间称为扫描周期,其典型值通常为1一100nis,不同PLC厂家的产品则略有不同。扫描周期由内部处理时间、输A/ 输出处理执行时间、指令执行时间等三部分组成。通常在一个扫描过程中,执行指令的时间占了绝大部分,而执行指令的时间与用户程序的长短有关。用户 程 序 是根据控制要求由用户编制,由许多条PLC指令所组成。不同的指令所对应的程序步不同,以三菱FX2N系列的PLC为例,PLC对每一个程序步操作处理时间为:基本指令占0.741s/步,功能指令占几百微米/步。完成一个控制任务可以有多种编制程序的方法,因此,选择合理、巧妙的编程方法既可以大大提高程序运行速度,又可以保证可靠性。 提高PLC程序运行速度的几种编程方法2.1 用数据传送给位元件组合的方法来控制输出在 PL C应 用编程中,最后都会有一段输出控制程序,一般都是用逻辑取及输出指令来编写,如图2所示。在图2所示的程序中,逻辑取的程序步为1,输出的程序步为2,执行上述程序共需3个程序步。通常情况下,PLC要控制的输出都不会是少量的,比如,有8个输出,在条件满足时要同时输出。此时,执行图2所示的程序共需17个程序步。若我们通过位元件的组合并采用数据传送的方法来完成图2所示的程序,就会大大减少程序步骤。在三 菱 PLC中,只处理ON/OFF状态的元件(如X,Y,M和S),称为位元件。但将位元件组合起来也可以处理数据。位元件组合由Kn加首元件号来表示。位元件每4bit为一组组合成单元。如KYO中的n是组数,当n=1时,K,Yo 对应的是Y3一Yo。当n二2时,KZYo对应的是Y7一Yo。通过位元件组合,就可以用处理数据的方式来处理位元件,图2程序所示的功能可用图3所示的传送数据的方式来完成。
上传时间: 2013-11-11
上传用户:几何公差
51单片机驱动步进电机(含电路图和源程序代码) 源程序: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() */
上传时间: 2013-11-09
上传用户:钓鳌牧马
PLC TM卡开发系统汇编程序(ATM8051) ;***************** 定义管脚*************************SCL BIT P1.0SDA BIT P1.1GC BIT P1.2BZ BIT P3.6LEDI BIT P1.4LEDII BIT P1.5OK BIT 20H.1OUT1 BIT P1.3OUT2 BIT P1.0OUT3 BIT P1.1RXD BIT P3.0TXD BIT P3.1PCV BIT P3.2WPC BIT P3.3RPC BIT P3.5LEDR BIT P3.4LEDL BIT P3.6TM BIT P3.7;********************定义寄存器***********************ROMDTA EQU 30H;NUMBY EQU 61H;SLA EQU 60H;MTD EQU 2FH;MRD EQU 40H;TEMP EQU 50H;;ORG 00H;;INDEX:MOV P1, #00H;MOV P2, #0FFHMOV MTD ,#00HCALL REEMOV R0,40HCJNE R0,#01,NO;MOV P2,#1CHLJMP VIMEN MOV P2,#79HACALL TOUCHRESET ;JNC NO ;CALL READTM ;CJNE A,#01H,NO;NOPMOV MTD, #00HCALL WEENOPMOV P2,#4AHSETB BZCALL TIMECLR BZMOV PCON, #0FFHVIME:CALL TIME1CALL TOUCHRESETJNC VIMECALL READTMCJNE A, #01H,VIME;NOPNOPNOPIII: MOV MTD,#00HCALL REECALL BBJNB OK,NO1LJMP ZHUNO1:MOV MTD,#10H
上传时间: 2014-03-24
上传用户:448949
用单片机配置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
自动检测80C51 串行通讯中的波特率本文介绍一种在80C51 串行通讯应用中自动检测波特率的方法。按照经验,程序起动后所接收到的第1 个字符用于测量波特率。这种方法可以不用设定难于记忆的开关,还可以免去在有关应用中使用多种不同波特率的烦恼。人们可以设想:一种可靠地实现自动波特检测的方法是可能的,它无须严格限制可被确认的字符。问题是:在各种的条件下,如何可以在大量允许出现的字符中找出波特率的定时间隔。显然,最快捷的方法是检测一个单独位时间(single bit time),以确定接收波特率应该是多少。可是,在RS-232 模式下,许多ASCII 字符并不能测量出一个单独位时间。对于大多数字符来说,只要波特率存在合理波动(这里的波特率是指标准波特率),从起始位到最后一位“可见”位的数据传输周期就会在一定范围内发生变化。此外,许多系统采用8 位数据、无奇偶校验的格式传输ASCII 字符。在这种格式里,普通ASCII 字节不会有MSB 设定
上传时间: 2013-10-15
上传用户:shirleyYim
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their productsor to discontinue any product or service without notice, and advise customers to obtain the latestversion of relevant information to verify, before placing orders, that information being relied onis current and complete. All products are sold subject to the terms and conditions of sale suppliedat the time of order acknowledgement, including those pertaining to warranty, patentinfringement, and limitation of liability
上传时间: 2013-12-26
上传用户:凌云御清风