欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    79F162_32 UART2759.docx

    • 资源ID:63473999       资源大小:40.92KB        全文页数:26页
    • 资源格式: DOCX        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    79F162_32 UART2759.docx

    79F162/32 UART 驱动 例子双UART功能Uart0_TTxd-P3.1口Uart0_RRxd-P3.0 口Uart1_IIRTxd-P2.7口Uart1_IIRRxd-P2.6口两路UART,其其中Uartt1内部有红红外硬件载波波发生器,可可以从Uarrt1_IRRTxd直接接发射调制的的UART红外外载波信号79F32系统统寄存器#ifndeff_CPU332_H#definee_CPU332_HsfrACCC=0xE0;sfrB=0xF0;sfrCRRE=0xF1;/*C reggisterr*/sfrPSSW=0xD0;sfrSPP=0x81;sfrDPPL=0x82;sfrDPPH=0x83;sfrDPPL1=0x84;/*Data pointter2 LLow byyte*/sfrDPPH1=0x85;/*Data pointter2 HHigh bbyte*/sfrINNSCON=0x86;/*Data pointter seelect*/*bit0 - 0: DPTR*bit0 - 1: DPTR 1*bit2 - 0: 8 bitt modee => (A*B) = B(High Byte)<<8 + A(Loow Bytte)*bit2 - 1: 16 biit modde=> (CA)*B= C(High Byte)<<16+ B(Miiddle Byte)<<8 + A (LLow Byyte)*bit3 - 0: 8 bitt modee => (A/B) = A(Quotiient llow byyte) + B(Reemaineer)*bit3 - 1: 16 biit modde=> (CA/BB)= C(Quotiient HHigh BByte)<<<8+ AA(Quottient Low BByte) + B(RRemainner)*/ sfrXPPAGE=0xF7;/*Memorry pagge*/sfrPCCON=0x87;/*powerr conttrol*/sfrSUUSLO=0x8E;/*suspeend moode coontroll*/sfrLPPDCON=0xB3;/*LPD ccontrool*/sfrIBB_CLK00=0xF9;/* fllash pprograammingg clocck reggisterr 0 */sfrIBB_CLK11=0xFA;/* flashh proggrammiing cllock rregistter 1 */sfrIBB_OFFSSET = 0xFB;/* Low bbyte ooffsett of fflash memorry forr proggrammiing */sfrIBB_DATAA= 0xFC;/* Data regisster ffor prrogrammming flashh memoory */sfrFOOCON=0xFD;/*flashh optiion coontroll*/sfrIBB_CON11=0xF2;/*Flashh memoory coontroll regiister 1*/sfrIBB_CON22=0xF3;/*Flashh memoory coontroll regiister 2*/sfrIBB_CON33=0xF4;/*Flashh memoory coontroll regiister 3*/sfrIBB_CON44=0xF5;/*Flashh memoory coontroll regiister 4*/sfrIBB_CON55=0xF6;/*Flashh memoory coontroll regiister 5*/sfrWDDT=0xB1;/*watchhdog ttimer contrrol*/sfrSCCM=0xB2;/*systeem cllock sselectt and monittor*/sfrIEEN0=0xA8;/*Exterrnal iinterrrupt eenablee conttrol 11*/sfrIEEN1=0xA9;/*Exterrnal iinterrrupt eenablee conttrol 22*/sfrIPPL0=0xB8;/*Interrrupt priorrity ccontrool Loww 0*/sfrIPPH0=0xB4;/*Interrrupt priorrity ccontrool Higgh 0*/sfrIPPL1=0xB9;/*Interrrupt priorrity ccontrool Loww 1*/sfrIPPH1=0xB5;/*Interrrupt priorrity ccontrool Higgh 1*/sfrP00=0x80;sfrP11=0x90;sfrP22=0xA0;sfrP33=0xB0;sfrP44=0xC0;sfrP00CR=0xE1;/*port 0 inpput/ouutput direcction contrrol*/sfrP11CR=0xE2;/*port 1 inpput/ouutput direcction contrrol*/sfrP22CR=0xE3;/*port 2 inpput/ouutput direcction contrrol*/sfrP33CR=0xE4;/*port 3 inpput/ouutput direcction contrrol*/sfrP44CR=0xE5;sfrPPP0CR=0xE9;/*Interrnal ppull-hhigh eenablee for port00*/sfrPPP1CR=0xEA;/*Interrnal ppull-hhigh eenablee for port11*/sfrPPP2CR=0xEB;/*Interrnal ppull-hhigh eenablee for port22*/sfrPPP3CR=0xEC;/*Interrnal ppull-hhigh eenablee for port33*/sfrPPP4CR=0xED;sfrTCCON=0x88;/*Timerr/Counnter 00 and 1 conntrol regisster*/sfrTMMOD=0x89;/*Timerr/Counnter 00 and 1 moddes*/sfrT00L=0x8A;/*Timerr/Counnter 00 low byte*/sfrT00H=0x8C;/*Timerr/Counnter 00 highh bytee*/sfrT11L=0x8B;/*Timerr/Counnter 11 low byte*/sfrT11H=0x8D;/*Timerr/Counnter 11 highh bytee*/sfrT22CON=0xC8;/*Timerr/Counnter 22 conttrol*/sfrT22MOD=0xC9;/*Timerr/Counnter 22 modee*/sfrRCCAP2L =0xCA;/*Timerr/Counnter 22 relooad/caapturee low byte*/sfrRCCAP2H =0xCB;/*Timerr/Counnter 22 relooad/caapturee highh bytee*/sfrT22L=0xCC;sfrT22H=0xCD;sfrSCCON=0x98;/*seriaal conntrol*/sfrSBBUF=0x99;/*seriaal datta bufffer*/sfrSAADDR=0x9A;/*slavee addrress*/sfrSAADEN=0x9B;/*slavee addrress mmask*/sfrSCCON1=0xD8;/*seriaal 1 ccontrool*/sfrSBBUF1=0xD9;sfrSAADDR1=0xDA;sfrSAADEN1=0xDB;sfrIRRCON=0xA1;/*IR coontroll*/sfrSPPCON=0xF8;/*SPI ccontrool*/sfrSPPSTA=0xA2;/*SPI sstatuss*/sfrSPPDAT=0xA3;/*SPI ddata*/sfrI22CCON=0xA6;sfrI22CDAT=0xA7;sfrADDCON=0x93;/*ADC ccontrool*/sfrADDCT=0x94;/*ADC ttime sselectt*/sfrADDCH=0x95;/*ADC cconfigguratiion*/sfrADDDL=0x96;/*ADC ddata bbufferr low nibblle*/sfrADDDH=0x97;sfrLCCDCON=0xAB;/*LCD ccontrool*/sfrLCCDCLK=0xAC;sfrP11SS=0xAD;/*P1 orr segmment sselectt*/sfrP00SS=0xAE;/*P0 orr segmment sselectt*/sfrPLLCON=0xAF;/*PWM LLCD coontroll*/sfrRTTCCON=0xBE;/*RTC ccontrool*/sfrRTTCDAT=0xBF;/*RTC ccalibrrationn dataa*/sfrSEECOND=0xC1;/*seconnd & hhalf ssecondd*/sfrMIINUTE=0xC2;sfrHOOUR=0xC3;sfrDAAY=0xC4;sfrMOONTH=0xC5;sfrYEEAR=0xC6;sfrWEEEK=0xC7;sfrPWWMEN=0xCF;/*PWM ttimer enablle*/sfrPWWMLO=0xE7;/*PWM cclock*/sfrPWWMC=0xD2;sfrPWWMPL=0xD3;sfrPWWMPH=0xD4;sfrPWWMDL=0xD5;sfrPWWMDH=0xD6;sfrPWWMDT=0xD1;/*PWM ddead ttime ccontrool*/sfrEXXF0=0xE8;/*exterrnal iinterrrupt 22 conttrol*/*Bittaddreessablle */sbitPP0_0=P00;sbitPP0_1=P01;sbitPP0_2=P02;sbitPP0_3=P03;sbitPP0_4=P04;sbitPP0_5=P05;sbitPP0_6=P06;sbitPP0_7=P07;sbitPP1_0=P10;sbitPP1_1=P11;sbitPP1_2=P12;sbitPP1_3=P13;sbitPP1_4=P14;sbitPP1_5=P15;sbitPP1_6=P16;sbitPP1_7=P17;sbitPP2_0=P20;sbitPP2_1=P21;sbitPP2_2=P22;sbitPP2_3=P23;sbitPP2_4=P24;sbitPP2_5=P25;sbitPP2_6=P26;sbitPP2_7=P27;sbitPP3_0=P30;sbitPP3_1=P31;sbitPP3_2=P32;sbitPP3_3=P33;sbitPP3_4=P34;sbitPP3_5=P35;sbitPP3_6=P36;sbitPP3_7=P37;sbitPP4_0=P40;sbitPP4_1=P41;sbitPP4_2=P42;sbitPP4_3=P43;sbitPP4_4=P44;sbitPP4_5=P45;sbitPP4_6=P46;sbitPP4_7=P47;sbit CY = 0xD7;/* carryy bit */sbit AC = 0xD6;/*BCD ccode ccarry bit*/sbit F0 = 0xD5;/*The FF0 flaag is used by seeverall aritthmetiic libbrary routiines. */sbit RS1 = 0xD4;/*RS0(11) sellect tthe cuurrentt workk regiister set*/sbit RS0 = 0xD3;sbit OV = 0xD2;/*calcuulate resullt oveerfloww*/sbitFF1=0xD1;/*The UUD/F1 flag is noot useed by any oof thee Keill deveelopmeent toools aand maay be used by yoour sooftwarre/harrdwaree.*/sbit P = 0xD0;/*ACC oodd/Evven chheck bbit*/sbit TF1 = 0x8F;/* Timerr 1 ovverfloow flaag bitt*/sbit TR1 = 0x8E;/*Timerr 1 sttart /stop contrrol biit*/sbit TF0 = 0x8D;/*Timerr 0 ovverfloow flaag bitt*/sbit TR0 = 0x8C;/*Timerr 0 sttart /stop contrrol biit*/sbit IE1 = 0x8B;/*Exterrnal iinterrrupt 11 requuest fflag*/sbit IT1 = 0x8A;/*Exterrnal iinterrrupt 11 triggger mmode: 0- llevel triggger;1- edgge triigger*/sbit IE0 = 0x89;/*Exterrnal iinterrrupt 00 requuest fflag*/sbit IT0 = 0x88;/*Exterrnal iinterrrupt 00 triggger mmode: 0- llevel triggger;1- edgge triigger*/sbit EA = IEN07;/0xAAF;/* all iinterrrupt eenablee bit*/sbitEEADC=0xAE;/*ADC iinterrrupt eenablee bit*/sbitEET2=0xAD;/*Timerr 2 innterruupt ennable bit*/sbit ES0 = 0xAC;/*EUARTT 0 innterruupt ennable bit*/sbit ET1 = 0xAB;/*Timerr 1 innterruupt ennable bit*/sbit EX1 = 0xAA;/*Exterrnal iinterrrupt 11 enabble biit */sbit ET0 = 0xA9;/*Timerr 0 innterruupt ennable bit*/sbit EX0 = 0xA8;/*Exterrnal 00 inteerruptt enabble biit*/sbit SM0 = 0x9F;/* selecct UARRT worrking mode*/sbit SM1 = 0x9E;/*selecct UARRT worrking mode*/sbit SM2 = 0x9D;/*0:siggnal mmachinne poiint too signnal maachinee; 1:NN poinnt N */sbit REN = 0x9C;/*0:dissable to reeceivee; 1: enabble too receeive*/sbit TB8 = 0x9B;/*Transsmit the 99th biit datta*/sbit RB8 = 0x9A;/*Receiive thhe 9thh bit data*/sbit TI = 0x99;/*Transsmit ddata iinterrrupt fflag*/sbit RI = 0x98;/*receiive daata innterruupt fllag*/sbitSSM10=0xDF;sbitSSM11=0xDE;sbitSSM12=0xDD;sbitRREN1=0xDC;sbitTTB81=0xDB;sbitRRB81=0xDA;sbitTTI1=0xD9;sbitRRI1=0xD8;sbitTTF2 =0xCF;/*T2CONN*/sbitEEXF2=0xCE;sbitRRCLK=0xCD;sbitTTCLK=0xCC;sbitEEXEN2=0xCB;sbitTTR2=0xCA;sbitCCT2=0xC9;sbitCCPRL2=0xC8;sbitPPADCL=0xAE;sbitPPT2L=0xAD;sbitPPSL=0xAC;sbitPPT1L=0xAB;sbitPPX1L=0xAA;sbitPPT0L=0xA9;sbitPPX0L=0xA8;sbitSSPEN=0xFF;/*SPSTAA*/sbitSSPIF=0xFE;sbitMMODF=0xFD;sbitWWCOL=0xFC;sbitRRXOV=0xFB;sbitIIE2=0xE9;/*EXF0*/sbitIIT2=0xE8;#endifUART的初始始化#defineeBAUDRRATE_66000/bauud ratte inddex vaalue sset:#defineeBAUDRRATE_112001#defineeBAUDRRATE_224002#defineeBAUDRRATE_448003#defineeBAUDRRATE_996004#defineeFSYSCCLK80000000/系统跑8M时钟#defineeBAUDRRATE_TTIME_6600(655336-FSYYSCLK/32/6000)/Sett BauddRate with Timerr 2 ,MMode 22.#defineeBAUDRRATE_TTIME_11200(655336-FSYYSCLK/32/12200)/Sett BauddRate with Timerr 2 ,MMode 22.#defineeBAUDRRATE_TTIME_22400(655336-FSYYSCLK/32/24400)/Sett BauddRate with Timerr 2 ,MMode 22.#defineeBAUDRRATE_TTIME_44800(655336-FSYYSCLK/32/48800)/Sett BauddRate with Timerr 2 ,MMode 22.#defineeBAUDRRATE_TTIME_99600(655336-FSYYSCLK/32/96600)/Sett BauddRate with Timerr 2 ,MMode 22.#defineeBAUDRRATE_TTIME_119200(655336-FSYYSCLK/32/199200)/Set BaudRRate wwith TTimer 2 ,Moode 2.#defineeOpCurrrentUUARTSppeedBAUDRRATE_11200/deffault selecction is 12200BPSS.voidSeetUARTTMode33(voidd)unsignned inntTimerr2Valuue ; #if (OpCCurrenntUARTTSpeedd = BBAUDRAATE_96600)Timerr2Valuue=BAUDRRATE_TTIME_99600; #eliff (OpCCurrenntUARTTSpeedd = BBAUDRAATE_12200)Timerr2Valuue=BAUDRRATE_TTIME_11200; #eliff (OpCCurrenntUARTTSpeedd = BBAUDRAATE_24400)Timerr2Valuue=BAUDRRATE_TTIME_22400; #eliff (OpCCurrenntUARTTSpeedd = BBAUDRAATE_48800)Timerr2Valuue=BAUDRRATE_TTIME_44800; #eliff (OpCCurrenntUARTTSpeedd = BBAUDRAATE_96600)Timerr2Valuue=BAUDRRATE_TTIME_99600; #elsee Timeer2Vallue=BAUDRRATE_TTIME_119200; #endiifT2MOD=Bin(0000000000);/Sett Timeer 2 BBaud-RRate ggeneraator mmode.RCAP2LL=LOBYTTE(Timmer2Vaalue);T2L=LOBYTTE(Timmer2Vaalue);RCAP2HH=HIBYTTE(Timmer2Vaalue);T2H=HIBYTTE(Timmer2Vaalue);T2CON=Bin(0001101100);/Timmer 2 is ussed ass EUARRT cloock soource,and hhas auutoloaad funnctionn.SCON=Bin(1110100000);/sellect mmode 33 ,enaable rreceivve,SM22=0,TBB8=1.SCON1=Bin(1110100000);PCON=Bin(0000000000);IRCON =128+ 104;/Bit77=1允许红红外载波功能能,载波频率率38K采用Timerr2作为UARTT载波基准时时钟,程序跑跑8M时钟,UARRT0和UART11设置为12000bps,UART11打开内部388k红外载波波发生器,UUART模式式3,开始位数据位基基偶位+停止位UART中断UART0 中中断允许位是是IEN0的Bit4,设设置为1就开启UARRT0中断UART1 中中断允许位是是IEN1的Bit2,设设置为1就开启UARRT1中断/ BBit7Bit6 Bit5 Bit44 Bitt3 Biit2 BBit1 Bit0 /IEN0 EA EADC ET22 ESS0 EET1 EX1 ET0 EX00 /IEN1 EFCOOF EII2C EEPWM ESCM EHSEEC ES11 EXX2 EESPI IEN0=Bin(0000100000);IEN1=Bin(0000001100);EA=1;/开全局中中断voidEUUART0_ISP(vvoid) interrrupt 4EA=00;/dissable all iinterrruptif(TI)/traansmitt workk end eventt.TI=00;ACC=gbUarrtBufffgbUaartLenn;/初始化被被发送的数据据TB81=P;/初始化校校验位SBUF11=ACC;./指向下一一个数据if(RI)/recceive one bbyte eevent.ACC=SBUF11;if( RRB81= P)/ Evven chheck!/校验正确确,保存数据据else/校验位错错误,错误处处理EA=11;voidEUUART1_ISP(vvoid) interrrupt 9EA=00;/dissable all iinterrruptif(TI11)/traansmitt workk end eventt.TI1 = 0;if(RI11)/recceive one bbyte eevent.EA=1;/enaable aall innterruupt如何发送数据:开始从UARTT0发送数据据,例如先发送一一个0xFEESBUF=0xFE;发送数据后,将将会发生UARTT0中断,然然后在中断后后继续发送后后续数据就可可以了如何接收数据:允许接收REN = 11;/允许UARTT0 RxddREN1= 11;/允许UARTT1 Rxdd允许接收后,有有收到数据将将会发生UAART中断,然然后在中断程程序中检查数数据校验位和和保存数据就就可以了

    注意事项

    本文(79F162_32 UART2759.docx)为本站会员(you****now)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开