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.
標(biāo)簽: software driver XA-S I2C
上傳時(shí)間: 2013-11-02
上傳用戶:zw380105939
The XA-S3 is a member of Philips Semiconductors’ XA (eXtended Architecture) family of high performance 16-bit single-chip Microcontrollers. The XA-S3 combines many powerful peripherals on one chip. Therefore, it is suited for general multipurpose high performance embedded control functions.One of the on-chip peripherals is the I2C bus interface. This report describes worked-out driver software (written in C) to program / use the I2C interface of the XA-S3. The driver software, together with a demo program and interface software routines offer the user a quick start in writing a complete I2C - XAS3 system application.
上傳時(shí)間: 2013-11-10
上傳用戶:liaofamous
基于AT89C2051的紅外遙控學(xué)習(xí)器源程序6 源程序 ORG 0000H AJMP MAIN ORG 0003H AJMP KEYPRESS ORG 000BH AJMP TIMEOUT ORG 001BH AJMP TIMEOUT SENDDUAN BIT P3.0 JIEDUAN BIT P3.1 INTRPO BIT P3.2 JIEXUAN BIT P3.3 SENDLIGHT BIT P3.4 JIELIGHT BIT P3.5 CS BIT P3.7 DATADUAN BIT P1.6 CLK BIT P1.7 JIANWEI EQU R5 JIANMA EQU R6 SHANGJIAN EQU 07H;R7 OPENKEY EQU 81H CLOSEKEY EQU 00H CHUT0 EQU 11H CHUT1 EQU 11H BUFBEGIN EQU 18H OPENT1 EQU 88H CLOSET1 EQU 00H OPENT0 EQU 82H CLOSET0 EQU 00H DATABEG1 EQU 0AAH DATABEG2 EQU 33H ORG 0030HMAIN: MOV IE,#80H MOV IP,#00H MOV P3,#0FFH CLR CS SETB P1.0 SETB P1.1 SETB P1.2 CLR P1.3 CLR P1.4 CLR P1.5 CLR P1.6 CLR P1.7 MOV R3,#80H MOV R0,00HCYCLE1: MOV @R0,#00H INC R0 DJNZ R3,CYCLE1 MOV PSW,#00H MOV SP,#07H MOV TMOD,#11H MOV TCON,#00H START: MOV SP,#07H SETB SENDDUAN CLR F0 SETB EXOWAITKEY: MOV C,F0 JNC WAITKEY CJNC JIANMA,#1BH,SEND LCALL LEARNP LJMP STARTSEND: LCALL SENDP LJMP START SENDP: SETB SENDDUAN CLR F0 MOV TMOD,#CHUT1
上傳時(shí)間: 2013-10-15
上傳用戶:lyy1234
//芯片資料請(qǐng)到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;}
上傳時(shí)間: 2013-11-03
上傳用戶:hongmo
T2作為波特率控制UART_RXD 是硬中斷0或1口,如果能進(jìn)入中斷,說明該線有一個(gè)起始位產(chǎn)生,進(jìn)入中斷后調(diào)用下面的接收程序。退出硬中斷之前還需要將硬中斷標(biāo)志重新復(fù)位。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,計(jì)數(shù)器2啟動(dòng),時(shí)間計(jì)數(shù)啟動(dòng)。 MOV A,RCAP2L;計(jì)數(shù)器2重新裝載值 MOV TL2,A ;置計(jì)數(shù)器2初值 ;T2需要重新裝載 MOV A,DPH MOV A,RCAP2H MOV TH2,A MOV A,R0 SETB TR2 ;TR2置1,計(jì)數(shù)器 JNB TF2,$ CLR TF2 JNB TF2,$ CLR TF2
上傳時(shí)間: 2014-01-12
上傳用戶:二十八號(hào)
#include <at24c01a.h>/*************************************************向24C01A寫入一個(gè)字節(jié)輸入:E2ROM地址,字節(jié)數(shù)據(jù)******************************************************/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();}/**********************************發(fā)送開始*****************************************/void start(void){a_scl=1;a_sda=1;a_sda=0;a_scl=0;a_scl=1;}/********************************************發(fā)送停止*******************************************/void stop(void){a_scl=0;a_sda=0;a_scl=1;a_sda=1;} /*********************************************發(fā)送反饋************************************************/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)}/**************************************發(fā)送無反饋********************************************/bit noack(void){int a_ack;a_scl=1;a_scl=1;a_scl=0;}/*******************************************發(fā)送****************************************************/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讀一個(gè)字節(jié);輸入:EEROM地址;輸出:EEROM數(shù)據(jù);********************************************/void read24c01a(uchar counter){receivebyte=0xa1;start();send(receivebyte);if (!ack())continue;send(counter);if (!ack())continue;receive()noack();stop();}
上傳時(shí)間: 2013-12-23
上傳用戶:wxhwjf
紅外遙控接收;=================================================;; zsMCU51實(shí)驗(yàn)板配套學(xué)習(xí)例程;; 中山單片機(jī)學(xué)習(xí)網(wǎng) 智佳科技;; 作者:逸風(fēng) QQ:105558851;; http://www.zsmcu.com; E-mail:info@zsmcu.com;=================================================ORG 0000HLJMP START;轉(zhuǎn)入主程序ORG 0010HSTART:MAIN:JNB P2.2,IRLJMP MAIN;以下為進(jìn)入P3.2腳外部中斷子程序,也就是解碼程序IR:MOV R6,#9SB:ACALL DELAY882 ;調(diào)用882微秒延時(shí)子程序JB P2.2,EXIT ;延時(shí)882微秒后判斷P3.2腳是否出現(xiàn)高電平如果有就退出解碼程序DJNZ R6, SB ;重復(fù)10次,目的是檢測(cè)在8820微秒內(nèi)如果出現(xiàn)高電平就退出解碼程序;以上完成對(duì)遙控信號(hào)的9000微秒的初始低電平信號(hào)的識(shí)別。JNB P2.2, $ ;等待高電平避開9毫秒低電平引導(dǎo)脈沖ACALL DELAY2400JNB P2.2,IR_Rp ;ACALL DELAY2400 ;延時(shí)4.74毫秒避開4.5毫秒的結(jié)果碼MOV R1,#1AH ;設(shè)定1AH為起始RAM區(qū)MOV R2,#4PP:MOV R3,#8JJJJ:JNB P2.2,$ ;等待地址碼第一位的高電平信號(hào)LCALL DELAY882 ;高電平開始后用882微秒的時(shí)間尺去判斷信號(hào)此時(shí)的高低電平狀態(tài)MOV C,P2.2 ;將P3.2引腳此時(shí)的電平狀態(tài)0或1存入C中 JNC UUU ;如果為0就跳轉(zhuǎn)到UUULCALL DELAY1000UUU:MOV A,@R1 ;將R1中地址的給ARRC A ;將C中的值0或1移入A中的最低位MOV @R1,A ;將A中的數(shù)暫時(shí)存放在R1中DJNZ R3,JJJJ ;接收地址碼的高8位INC R1 ;對(duì)R1中的值加1,換下一個(gè)RAMDJNZ R2,PP ;接收完16位地址碼和8位數(shù)據(jù)碼和8位數(shù)據(jù),存放在1AH/1BH/1CH/1DH的RAM中MOV P1,1DH ;將按鍵的鍵值通過P1口的8個(gè)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
上傳時(shí)間: 2013-11-01
上傳用戶:2525775
系統(tǒng)start-up 定時(shí)器• 為了讓振蕩器能夠穩(wěn)定起振所需要的延時(shí)時(shí)間。• 其時(shí)間為1024 個(gè)振蕩器振蕩周期。制程和溫度漂移• 因RC 振蕩器的頻率與內(nèi)建振蕩電容值有關(guān),而此電容值與制程參數(shù)有關(guān),所以不同的MCU 會(huì)表現(xiàn)出不一致性。在固定電壓和溫度下,振蕩頻率漂移范圍約±25%。• 對(duì)于同一顆MCU(與制程漂移無關(guān)),其振蕩頻率會(huì)對(duì)工作電壓和工作溫度產(chǎn)生漂移。其對(duì)工作電壓和工作溫度所產(chǎn)生的漂移,可參考HOLTEK 網(wǎng)站上提供的相關(guān)資料。EMI/EMS(EMC)注意事項(xiàng)• ROSC 位置應(yīng)盡量接近OSC1 引腳,其至OSC1 的連線應(yīng)最短。• CS 可以提高振蕩器的抗干擾能力,其與MCU OSC1 和GND 的連線應(yīng)最短。• RPU 在確定系統(tǒng)頻率之后,量產(chǎn)時(shí)建議不要接,因?yàn)槠鋐SYS/4 頻率輸出會(huì)干擾到OSC1
上傳時(shí)間: 2014-01-20
上傳用戶:yyyyyyyyyy
用單片機(jī)配置FPGA—PLD設(shè)計(jì)技巧 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
標(biāo)簽: FPGA PLD 用單片機(jī) 設(shè)計(jì)技巧
上傳時(shí)間: 2013-10-09
上傳用戶:a67818601
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 〖修改〗修改建議請(qǐng)到論壇公布 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
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1