预览加载中,请您耐心等待几秒...
1/3
2/3
3/3

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

串口函数总结 串口的初始化 voidUART0_Init(intmclk,intbaud) { if(mclk==0)mclk=MCLK; rPCONE=0x28; rULCON0=0x3; rUCON0=0x245; rUBRDIV0=((int)(mclk/16./baud+0.5)-1); } voidUART1_Init(intmclk,intbaud) { if(mclk==0)mclk=MCLK; rPCONE=0x28; rULCON0=0x3; rUCON0=0x245; rUBRDIV0=((int)(mclk/16./baud+0.5)-1); } 查询方式发送数据 voidUART0_SendByte(uint8data) { rUTXH0=data; while((rUTRSTAT0&0x2)==0); } 查询方式接收 VoidUART0_RcvByte((uint8data) { uint8rcv_data; while((rUTRSTAT0&0x01)==0); rcv_data=rURXH0; return(rcv_data); } 使用外部中断发送和接收字符的函数: #include"44blib.h" #include"44b.h" #include"stdio.h" voidMain(void); externvoidEint4567Isr(void)__attribute__((interrupt("IRQ"))); voidinit_Eint(void); voidMain(void) { sys_init();/*初始化s3c44B0XInterrupt,PortandUART*/ _Link(); init_Eint(); Uart_Printf("\n\rEmbest44B0XEvaluationBoard(S3CEV40)"); Uart_Printf("\n\r8-segmentDigitLEDTestExample(PleaselookatLED)\n"); for(;;) { ; } } #include"44b.h" #include"44blib.h" voidEint4567Isr(void)__attribute__((interrupt("IRQ"))); voidinit_Eint(void); externvoidDelay(inttime); voidinit_Eint(void) { rI_ISPC=0x3ffffff; rEXTINTPND=0xf;//clearEXTINTPNDreg rINTMOD=0x0; rINTCON=0x1; rINTMSK=~(BIT_GLOBAL|BIT_EINT4567); pISR_EINT4567=(int)Eint4567Isr; /*PORTG*/ rPCONG=0xffff;//EINT7~0 rPUPG=0x0;//pullupenable rEXTINT=rEXTINT|0x22220000;//EINT1、EINT4567fallingedgemode rI_ISPC|=BIT_EINT4567; rEXTINTPND=0xf;//clearEXTINTPNDreg } voidEint4567Isr(void) { chari; unsignedcharwhich_int; which_int=rEXTINTPND; rEXTINTPND=0xf; //clearEXTINTPNDreg. rI_ISPC=BIT_EINT4567; //clearpending_bit if(which_int==4) //SB2 { Uart_Printf("发送:\n"); Uart_SendByte('*'); } elseif(which_int==8) //SB3 {Uart_Printf("接收:\n"); i=Uart_Getch(); Uart_Printf("%c\n",i); } }