位置:51电子网 » 技术资料 » 其它综合

用软件仿真串口

发布时间: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

;*******************************************************************************
相关IC型号

热门点击

 

推荐技术资料

罗盘误差及补偿
    造成罗盘误差的主要因素有传感器误差、其他磁材料干扰等。... [详细]
版权所有:51dzw.COM
深圳服务热线:13751165337  13692101218
粤ICP备09112631号-6(miitbeian.gov.cn)
公网安备44030402000607
深圳市碧威特网络技术有限公司
付款方式


 复制成功!