用软件仿真串口
发布时间:2008/6/5 0:00:00 访问次数:766
;*******************************************************************************
;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中的关键字
上一篇:车距语言提醒器 (一)