freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

pc機與單片機的通訊設(shè)計-資料下載頁

2024-07-22 20:21本頁面

【導(dǎo)讀】大多數(shù)的電腦設(shè)備都具有RS-232C接口,盡管它的性能指標并非很好。的市場支持下依然常勝不衰。就使用而言,RS-232也確實有其優(yōu)勢:僅需3根線便??稍趦蓚€數(shù)字設(shè)備之間全雙工的傳送數(shù)據(jù)。訊的打印機接口更難于控制。RS-232C使用了遠較并行口更多的寄存器。器用來實現(xiàn)串行數(shù)據(jù)的傳送及RS-232C設(shè)備之間的握手與流量控制。述PC機及單片機MCS-51的串行通訊的原理及具體的軟件設(shè)計。中國最大的資料庫下載。的邏輯“0”,緊隨其后為所要傳送的數(shù)據(jù),所要傳送的數(shù)據(jù)有最低位開始依此送出,并以一個結(jié)束位標志該字節(jié)傳送結(jié)束,結(jié)束位為一個寬度的邏輯“1”狀態(tài)。插件將串行口的信號送出。該插座的信號定義如下:。懸空這視乎你的通訊軟件。比如說,如果使用DOS所提供的BIOS通訊驅(qū)動程序,0400-0000:0406中描述,對應(yīng)地址分別為3F8/2F8/3E8/2E8,COM1及COM3使。用PC機中斷4,COM2及COM4使用中斷3。地址,由DLAB=0/1來區(qū)分,在DLAB=1用于設(shè)定通訊所需的波特率。Bit3用來指示超時中斷。中斷,而MSR中斷級別最低。

  

【正文】 FlagTransIdle = 1。 FlagCvtInCR = 1。 /* want to turn CRs into LFs */ RR_iHead = RR_iTail = RR_cLev = RR_cMax = 0。 TR_iHead = TR_iTail = TR_cLev = TR_cMax = 0。 UnGotCh = 1。 /* set up Timer 1 to produce serial rate */ TCON amp。= 0x3F。 /* clear run amp。 interrupt flags */ TMOD amp。= 0x0F。 /* flush existing Timer 1 setup */ TMOD |= 0x20。 /* flush existing Timer 1 setup */ SCON = 0x50。 /* flush existing Timer 1 setup */ PCON |= 0x00。 TH1 = TL1 = T1RELOAD amp。 0x00FF。 /* flush existing Timer 1 setup */ TR1 = 1。 /* start the timer */ ES = 1。 /* enable serial interrupts */ } 中國最龐大的下資料庫 (整理 . 版權(quán)歸原作者所有 ) 第 38 頁 共 42 頁 /**/ /* Serial console interrupt handler */ /* If transmitter output is disabled, we fake trans interrupts until empty */ void SerInt() interrupt 4 { if(RI) { /* receiver interrupt active? */ if(RR_cLevINRINGSIZE) { /* room for newest char? */ RRing[RR_iHead] = SBUF。 /* pick up the character and stick in ring */ RR_iHead++。 /* tick the index */ RR_cLev++。 /* tick size counter */ if(RR_iHead==INRINGSIZE) RR_iHead = 0。 /* hit end of array yet? */ } RI = 0。 /* indicate we have it */ } if(TI) { /* transmitter interrupt active? */ if(TR_cLev) { /* anything to send? */ SBUF = TRing[TR_iTail]。 /* fetch next char and send it */ TR_cLev。 /* tick size counter */ TR_iTail++。 /* tick the index */ if(TR_iTail==OUTRINGSIZE) TR_iTail = 0。 /* hit end of array yet? */ } else FlagTransIdle = 1。/* no, flag inactive */ TI = 0。 /* indicate done with it */ } } /**/ /* Send character to console */ 中國最龐大的下資料庫 (整理 . 版權(quán)歸原作者所有 ) 第 39 頁 共 42 頁 /* Can strip LFs, in which case you get CR instead of LF/CR */ int putch(int TransChar) { putc(TransChar)。 /* if not LF, handle normally */ if(TransChar==39。\n39。) putc(39。\r39。)。 /* if LF, send a CR */ } int putc(int TransChar) { while(TR_cLev=OUTRINGSIZE)。 /* wait for space in ring */ ES = 0。 TRing[TR_iHead] = TransChar。 /* point to char slot */ TR_iHead++。 /* tick counter amp。 index */ TR_cLev++。 if(TR_iHead==OUTRINGSIZE) TR_iHead = 0。 if(FlagTransIdle) { FlagTransIdle = 0。 /* kickstart transmitter if idle */ TI = 1。 } ES = 1。 return(TransChar)。 } /**/ /* Decide if there are any pending chars */ /* Returns nonzero if there39。s a char */ int chkch() { 中國最龐大的下資料庫 (整理 . 版權(quán)歸原作者所有 ) 第 40 頁 共 42 頁 return(RR_cLev)。 /* tack on current level */ } /**/ /* Wait for the serial transmitter to go idle */ /* If the transmitter is disabled, that39。s considered to be the same thing */ void SerWaitOutDone() { while (TR_cLev)。 /* wait for ring empty */ while(!FlagTransIdle)。 /* wait for last char */ } /**/ /* Flush the input buffer */ /* Returns number of chars flushed */ int SerFlushIn() { ES = 0。 /* turn off serial interrupts */ RR_iTail = 0。 /* reset ring variables */ RR_iHead = 0。 RR_cLev = 0。 ES = 1。 /* turn on serial interrupts */ } /**/ /* Get character from console */ /* CRs turn into LFs unless we39。re not doing that... */ 中國最龐大的下資料庫 (整理 . 版權(quán)歸原作者所有 ) 第 41 頁 共 42 頁 int getch() { int RetVal。 ES = 0。 /* avoid interruptions */ if(RR_cLev) { /* anything pending? */ RetVal = RRing[RR_iTail]。 if(RetVal==39。\r39。) RetVal = 39。\n39。 /* use LF instead of CR */ RR_iTail++。 /* tick size index amp。 counter */ RR_cLev。 if(RR_iTail==INRINGSIZE) RR_iTail = 0。 /* hit end of array yet? */ } else RetVal = 1。 ES = 1。 return(RetVal)。 } /**/ /* Send string to console */ /* putstr(char *pString)。 */ /* The ?putstr entry point has *pString in DPTR */ int putstr (char *pstring) { while(*pstring) { /* fetch character if zero done */ putch(*pstring)。 pstring++。 /* continue... */ } } 中國最龐大的下資料庫 (整理 . 版權(quán)歸原作者所有 ) 第 42 頁 共 42 頁 使用查詢的程序可以做到多高的波特率取決于主程序的工作量,使用中斷方式的通訊驅(qū)動程序在使用 的速率。 ( 5) 關(guān)于 RS485 以上幾個方面詳細介紹了 PC 及 MCS51 的 RS232C 的串行通訊程序的設(shè)計方法, RS485 與 RS232C 相類似,其區(qū)別在于使用雙端平衡驅(qū)動及半雙工模式,這些措施使 RS485 傳輸距離更遠,同時, RS485 還可以組網(wǎng)。在同一個 RS485 網(wǎng)絡(luò)中,可以多達 32 個模塊,某些器件可以多達 256 個甚至更多。相應(yīng)的, RS485具有接收 /發(fā)送控制端, RS485 的接收控制端可以在需要接收的時候打開或者一直打開以便無條件的接收線路上的數(shù)據(jù)。 RS485 的發(fā)送控制 端僅在需要發(fā)送時打開,平時應(yīng)關(guān)端發(fā)送器,因為在同一 RS485網(wǎng)絡(luò)中在同一時刻僅允許一個發(fā)送器工作。在數(shù)據(jù)發(fā)送完成后關(guān)閉發(fā)送器。這可以通過以下兩種方法實現(xiàn)。 一、在數(shù)據(jù)完全移出后,對于 PC 機為發(fā)送移位寄存器空,對于 MCS51 為 TI置位。這些調(diào)件既可使用查詢的方法得到,也可以在中斷程序中實現(xiàn)。 二、將 RS485 的接收器始終打開,這樣一來,所有在 RS485 上的數(shù)據(jù)均被接收回來,包括自己發(fā)送出去的數(shù)據(jù)。因此,當自己發(fā)送的數(shù)據(jù)完全被自己接收回來時即可關(guān)閉發(fā)送器。原則上說,這一方法無論是查詢或中斷方 式都適用,但實際上,由于 RS485 的數(shù)據(jù)通常打包后發(fā)送,因此,使用查詢的方法并不理想。這一方法非常適合中斷方式,尤其是以數(shù)據(jù)包傳送的 RS485 通訊。
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1