用軟件仿真串口
發(fā)布時(shí)間:2008/6/5 0:00:00 訪問次數(shù):771
;*******************************************************************************
;duplexuartroutinesforthe8xc751and8xc752microcontrollers
;*******************************************************************************
;thisisademoprogramshowingawaytoperformsimultaneousrs-232
;transmitandreceiveusingonlyonehardwaretimer.
;thetransmitandreceiveroutinesdivideeachbittimeinto4slicesto
;allowsynchronizingtoincomingdatathatmaybeoutofsynchwithoutgoing
;data.
;themainprogramloopinthisdemoprocessesreceiveddataandsendsit
;backtothetransmitterinhexadecimalformat.thisinsuresthatwecan
;alwaysfillupthereceiverbuffer(sincethereturneddataislongerthan
;thereceiveddata)fortestingpurposes.example:iftheletter"a"is
;received,wewillecho"a41".
;*******************************************************************************
;$title(duplexuartroutinesforthe751/752)
;$date(8/20/92)
;$mod751
;*******************************************************************************
;definitions
;*******************************************************************************
;miscellaneous
txbitlenequ-4+1;timerslicesperserialbittransmit.
rxbitlenequ-4+1;timerslicesperserialbitreceive.
rxhalfbitequ(rxbitlen/4)+1;timerslicesforapartialbittime.
;usedtoadjusttheinputsampling
;timepoint.
;note:txbitlenandrxbitlenarekeptseparateinordertofacilitatethe
;possibilityofhavingdifferenttransmitandreceivebaudrates.thetimer
;wouldbesetuptogivefourslicesforthefastestbaudrate,andthe
;bitlenfortheslowerchannelwouldbesetlongerfortheslowerbaudrate.
;bitlen=-4+1givesfourtimerinterruptsperbit.bitlen=-8+1would
;give8slices,bitlen=-16+1wouldgive16slices,etc.
txpinbitp1.0;rs-232transmitpin(output).
rxpinbitp3.2;rs-232receivepin(input).
rtsbitp1.3;rs-232requesttosendpin(output).
ctsbitp1.6;rs-232cleartosendpin(input).
;note:p1.1andp1.2areusedtoinputthebaudrateselection.
;ramlocations
flagsdata20h;miscellaneousbitflags(seebelow).
txonbitflags.0;indicatestransmitterison(busy).
rxonbitflags.1;indicatesreceiverison(busy).
txfullbitflags.2;transmitbuffer(1byteonly)isfull.
rxfullbitflags.3;receiverbufferisfull.
rxavailbitflags.4;rxbufferisnotempty.
overrunerrbitflags.6;overrunerrorflag.
framingerrbitflags.7;framingerrorflag.
baudhighdata21h;highbytetimervalueforbaudrate.
baudlowdata22h;lowbytetimervalueforbaudrate.
txcntdata23h;rs-232bytetransmitbitcounter.
txtimedata24h;rs-232transmittimeslicecount.
txshiftdata25h;transmittershiftregister.
txdatdata26h;transmitterholdingregister.
rxcntdata27h;rs-232bytereceivebitcounter.
rxtimedata28h;rs-232receivetimeslicecount.
rxshiftdata29h;receivershiftregister.
rxdatcntdata2ah;receivedbytecount.
rxbufdata2bh;receivebuffer(3byteslong).
tempdata2fh;temporaryholdingregister.
rthdata40h
rtldata41h
;*******************************************************************************
;interruptvectors
;*******************************************************************************
org00h;resetvector.
ajmpreset
org03h;externalinterrupt0
ajmpintr0;(receivedrs-232startbit).
org0bh;timer0overflowinterrupt.
ajmptimer0;(4xthers-232bitrate).
org13h;externalinterrupt1.
reti;(notused).
org1bh;timeriinterrupt.
reti;(notused).
org23h;i2cinterrupt.
reti;(notused).
;*******************************************************************************
;interrupthandlers
;*******************************************************************************
;duplexuartroutinesforthe8xc751and8xc752microcontrollers
;*******************************************************************************
;thisisademoprogramshowingawaytoperformsimultaneousrs-232
;transmitandreceiveusingonlyonehardwaretimer.
;thetransmitandreceiveroutinesdivideeachbittimeinto4slicesto
;allowsynchronizingtoincomingdatathatmaybeoutofsynchwithoutgoing
;data.
;themainprogramloopinthisdemoprocessesreceiveddataandsendsit
;backtothetransmitterinhexadecimalformat.thisinsuresthatwecan
;alwaysfillupthereceiverbuffer(sincethereturneddataislongerthan
;thereceiveddata)fortestingpurposes.example:iftheletter"a"is
;received,wewillecho"a41".
;*******************************************************************************
;$title(duplexuartroutinesforthe751/752)
;$date(8/20/92)
;$mod751
;*******************************************************************************
;definitions
;*******************************************************************************
;miscellaneous
txbitlenequ-4+1;timerslicesperserialbittransmit.
rxbitlenequ-4+1;timerslicesperserialbitreceive.
rxhalfbitequ(rxbitlen/4)+1;timerslicesforapartialbittime.
;usedtoadjusttheinputsampling
;timepoint.
;note:txbitlenandrxbitlenarekeptseparateinordertofacilitatethe
;possibilityofhavingdifferenttransmitandreceivebaudrates.thetimer
;wouldbesetuptogivefourslicesforthefastestbaudrate,andthe
;bitlenfortheslowerchannelwouldbesetlongerfortheslowerbaudrate.
;bitlen=-4+1givesfourtimerinterruptsperbit.bitlen=-8+1would
;give8slices,bitlen=-16+1wouldgive16slices,etc.
txpinbitp1.0;rs-232transmitpin(output).
rxpinbitp3.2;rs-232receivepin(input).
rtsbitp1.3;rs-232requesttosendpin(output).
ctsbitp1.6;rs-232cleartosendpin(input).
;note:p1.1andp1.2areusedtoinputthebaudrateselection.
;ramlocations
flagsdata20h;miscellaneousbitflags(seebelow).
txonbitflags.0;indicatestransmitterison(busy).
rxonbitflags.1;indicatesreceiverison(busy).
txfullbitflags.2;transmitbuffer(1byteonly)isfull.
rxfullbitflags.3;receiverbufferisfull.
rxavailbitflags.4;rxbufferisnotempty.
overrunerrbitflags.6;overrunerrorflag.
framingerrbitflags.7;framingerrorflag.
baudhighdata21h;highbytetimervalueforbaudrate.
baudlowdata22h;lowbytetimervalueforbaudrate.
txcntdata23h;rs-232bytetransmitbitcounter.
txtimedata24h;rs-232transmittimeslicecount.
txshiftdata25h;transmittershiftregister.
txdatdata26h;transmitterholdingregister.
rxcntdata27h;rs-232bytereceivebitcounter.
rxtimedata28h;rs-232receivetimeslicecount.
rxshiftdata29h;receivershiftregister.
rxdatcntdata2ah;receivedbytecount.
rxbufdata2bh;receivebuffer(3byteslong).
tempdata2fh;temporaryholdingregister.
rthdata40h
rtldata41h
;*******************************************************************************
;interruptvectors
;*******************************************************************************
org00h;resetvector.
ajmpreset
org03h;externalinterrupt0
ajmpintr0;(receivedrs-232startbit).
org0bh;timer0overflowinterrupt.
ajmptimer0;(4xthers-232bitrate).
org13h;externalinterrupt1.
reti;(notused).
org1bh;timeriinterrupt.
reti;(notused).
org23h;i2cinterrupt.
reti;(notused).
;*******************************************************************************
;interrupthandlers
;*******************************************************************************
;*******************************************************************************
;duplexuartroutinesforthe8xc751and8xc752microcontrollers
;*******************************************************************************
;thisisademoprogramshowingawaytoperformsimultaneousrs-232
;transmitandreceiveusingonlyonehardwaretimer.
;thetransmitandreceiveroutinesdivideeachbittimeinto4slicesto
;allowsynchronizingtoincomingdatathatmaybeoutofsynchwithoutgoing
;data.
;themainprogramloopinthisdemoprocessesreceiveddataandsendsit
;backtothetransmitterinhexadecimalformat.thisinsuresthatwecan
;alwaysfillupthereceiverbuffer(sincethereturneddataislongerthan
;thereceiveddata)fortestingpurposes.example:iftheletter"a"is
;received,wewillecho"a41".
;*******************************************************************************
;$title(duplexuartroutinesforthe751/752)
;$date(8/20/92)
;$mod751
;*******************************************************************************
;definitions
;*******************************************************************************
;miscellaneous
txbitlenequ-4+1;timerslicesperserialbittransmit.
rxbitlenequ-4+1;timerslicesperserialbitreceive.
rxhalfbitequ(rxbitlen/4)+1;timerslicesforapartialbittime.
;usedtoadjusttheinputsampling
;timepoint.
;note:txbitlenandrxbitlenarekeptseparateinordertofacilitatethe
;possibilityofhavingdifferenttransmitandreceivebaudrates.thetimer
;wouldbesetuptogivefourslicesforthefastestbaudrate,andthe
;bitlenfortheslowerchannelwouldbesetlongerfortheslowerbaudrate.
;bitlen=-4+1givesfourtimerinterruptsperbit.bitlen=-8+1would
;give8slices,bitlen=-16+1wouldgive16slices,etc.
txpinbitp1.0;rs-232transmitpin(output).
rxpinbitp3.2;rs-232receivepin(input).
rtsbitp1.3;rs-232requesttosendpin(output).
ctsbitp1.6;rs-232cleartosendpin(input).
;note:p1.1andp1.2areusedtoinputthebaudrateselection.
;ramlocations
flagsdata20h;miscellaneousbitflags(seebelow).
txonbitflags.0;indicatestransmitterison(busy).
rxonbitflags.1;indicatesreceiverison(busy).
txfullbitflags.2;transmitbuffer(1byteonly)isfull.
rxfullbitflags.3;receiverbufferisfull.
rxavailbitflags.4;rxbufferisnotempty.
overrunerrbitflags.6;overrunerrorflag.
framingerrbitflags.7;framingerrorflag.
baudhighdata21h;highbytetimervalueforbaudrate.
baudlowdata22h;lowbytetimervalueforbaudrate.
txcntdata23h;rs-232bytetransmitbitcounter.
txtimedata24h;rs-232transmittimeslicecount.
txshiftdata25h;transmittershiftregister.
txdatdata26h;transmitterholdingregister.
rxcntdata27h;rs-232bytereceivebitcounter.
rxtimedata28h;rs-232receivetimeslicecount.
rxshiftdata29h;receivershiftregister.
rxdatcntdata2ah;receivedbytecount.
rxbufdata2bh;receivebuffer(3byteslong).
tempdata2fh;temporaryholdingregister.
rthdata40h
rtldata41h
;*******************************************************************************
;interruptvectors
;*******************************************************************************
org00h;resetvector.
ajmpreset
org03h;externalinterrupt0
ajmpintr0;(receivedrs-232startbit).
org0bh;timer0overflowinterrupt.
ajmptimer0;(4xthers-232bitrate).
org13h;externalinterrupt1.
reti;(notused).
org1bh;timeriinterrupt.
reti;(notused).
org23h;i2cinterrupt.
reti;(notused).
;*******************************************************************************
;interrupthandlers
;*******************************************************************************
;duplexuartroutinesforthe8xc751and8xc752microcontrollers
;*******************************************************************************
;thisisademoprogramshowingawaytoperformsimultaneousrs-232
;transmitandreceiveusingonlyonehardwaretimer.
;thetransmitandreceiveroutinesdivideeachbittimeinto4slicesto
;allowsynchronizingtoincomingdatathatmaybeoutofsynchwithoutgoing
;data.
;themainprogramloopinthisdemoprocessesreceiveddataandsendsit
;backtothetransmitterinhexadecimalformat.thisinsuresthatwecan
;alwaysfillupthereceiverbuffer(sincethereturneddataislongerthan
;thereceiveddata)fortestingpurposes.example:iftheletter"a"is
;received,wewillecho"a41".
;*******************************************************************************
;$title(duplexuartroutinesforthe751/752)
;$date(8/20/92)
;$mod751
;*******************************************************************************
;definitions
;*******************************************************************************
;miscellaneous
txbitlenequ-4+1;timerslicesperserialbittransmit.
rxbitlenequ-4+1;timerslicesperserialbitreceive.
rxhalfbitequ(rxbitlen/4)+1;timerslicesforapartialbittime.
;usedtoadjusttheinputsampling
;timepoint.
;note:txbitlenandrxbitlenarekeptseparateinordertofacilitatethe
;possibilityofhavingdifferenttransmitandreceivebaudrates.thetimer
;wouldbesetuptogivefourslicesforthefastestbaudrate,andthe
;bitlenfortheslowerchannelwouldbesetlongerfortheslowerbaudrate.
;bitlen=-4+1givesfourtimerinterruptsperbit.bitlen=-8+1would
;give8slices,bitlen=-16+1wouldgive16slices,etc.
txpinbitp1.0;rs-232transmitpin(output).
rxpinbitp3.2;rs-232receivepin(input).
rtsbitp1.3;rs-232requesttosendpin(output).
ctsbitp1.6;rs-232cleartosendpin(input).
;note:p1.1andp1.2areusedtoinputthebaudrateselection.
;ramlocations
flagsdata20h;miscellaneousbitflags(seebelow).
txonbitflags.0;indicatestransmitterison(busy).
rxonbitflags.1;indicatesreceiverison(busy).
txfullbitflags.2;transmitbuffer(1byteonly)isfull.
rxfullbitflags.3;receiverbufferisfull.
rxavailbitflags.4;rxbufferisnotempty.
overrunerrbitflags.6;overrunerrorflag.
framingerrbitflags.7;framingerrorflag.
baudhighdata21h;highbytetimervalueforbaudrate.
baudlowdata22h;lowbytetimervalueforbaudrate.
txcntdata23h;rs-232bytetransmitbitcounter.
txtimedata24h;rs-232transmittimeslicecount.
txshiftdata25h;transmittershiftregister.
txdatdata26h;transmitterholdingregister.
rxcntdata27h;rs-232bytereceivebitcounter.
rxtimedata28h;rs-232receivetimeslicecount.
rxshiftdata29h;receivershiftregister.
rxdatcntdata2ah;receivedbytecount.
rxbufdata2bh;receivebuffer(3byteslong).
tempdata2fh;temporaryholdingregister.
rthdata40h
rtldata41h
;*******************************************************************************
;interruptvectors
;*******************************************************************************
org00h;resetvector.
ajmpreset
org03h;externalinterrupt0
ajmpintr0;(receivedrs-232startbit).
org0bh;timer0overflowinterrupt.
ajmptimer0;(4xthers-232bitrate).
org13h;externalinterrupt1.
reti;(notused).
org1bh;timeriinterrupt.
reti;(notused).
org23h;i2cinterrupt.
reti;(notused).
;*******************************************************************************
;interrupthandlers
;*******************************************************************************
上一篇:C51中的關(guān)鍵字
上一篇:車距語言提醒器 (一)
熱門點(diǎn)擊
- 彩電屢燒行管的幾點(diǎn)問題討論
- 真空斷路器的合閘彈跳與分閘彈振研究
- 電子羅盤
- Actel面向FPGA設(shè)計(jì)的新版IDE支持添
- FCS在大容量滌綸短纖紡絲生產(chǎn)線中的應(yīng)用
- TI推出單芯片交錯(cuò)式功率因數(shù)校正控制電路UC
- C51中的關(guān)鍵字
- USB1.1和USB2.0相關(guān)標(biāo)準(zhǔn)
- 發(fā)動(dòng)機(jī)缺水報(bào)警器 (一)
- 感應(yīng)式防盜報(bào)警器 (五)
推薦技術(shù)資料
- 羅盤誤差及補(bǔ)償
- 造成羅盤誤差的主要因素有傳感器誤差、其他磁材料干擾等。... [詳細(xì)]
- 電源管理 IC (PMIC)&
- I2C 接口和 PmBUS 以及 OTP/M
- MOSFET 和柵極驅(qū)動(dòng)器單
- 數(shù)字恒定導(dǎo)通時(shí)間控制模式(CO
- Power Management Buck/
- 反激變換器傳導(dǎo)和輻射電磁干擾分析和抑制技術(shù)
- 多媒體協(xié)處理器SM501在嵌入式系統(tǒng)中的應(yīng)用
- 基于IEEE802.11b的EPA溫度變送器
- QUICCEngine新引擎推動(dòng)IP網(wǎng)絡(luò)革新
- SoC面世八年后的產(chǎn)業(yè)機(jī)遇
- MPC8xx系列處理器的嵌入式系統(tǒng)電源設(shè)計(jì)
- dsPIC及其在交流變頻調(diào)速中的應(yīng)用研究