<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          S3C2440-UART

          作者: 時(shí)間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
          S3C2440通用異步接收器和發(fā)送器(UART)提供了3個(gè)獨(dú)立的異步串行IO端口,每個(gè)端口可以在中斷模式或DMA模式下操作。換言之,UART可以生成一個(gè)中斷或DMA請(qǐng)求進(jìn)行CPU和UART之間數(shù)據(jù)的傳輸。如果一個(gè)外部設(shè)備提供UEXTLCK給UART,UART可以在更高的速度下工作。每個(gè)UART通道對(duì)于接受器和發(fā)送器包括2個(gè)64字節(jié)的FIFO和移位器。數(shù)據(jù)拷貝到FIFO然后在傳送之前拷貝到發(fā)送移位器。數(shù)據(jù)通過發(fā)送引腳(TxDn)被發(fā)出。同時(shí),接受數(shù)據(jù)通過接受數(shù)據(jù)引腳(RxDn)移入,然后從移位寄存器拷貝到FIFO。波特率由時(shí)鐘源(PCLK,F(xiàn)CLK/n,UEXTCLK)16分頻和UART波特率除數(shù)寄存器UBRDIVn指定的16位除數(shù)決定。波特率除數(shù)因子UBRDIVn的計(jì)算公式為,UBRDIVn=(int)(UART clock)/(buad rate * 16)) - 1。

          這個(gè)程序可以通過串口調(diào)試助手發(fā)送一個(gè)字符,然后在接受的地方顯示出來。

          #define rULCON0 (*(volatile unsigned*) 0x50000000)
          #define rUCON0 (*(volatile unsigned*) 0x50000004)
          #define rUTRSTAT0 (*(volatile unsigned*) 0x50000010)
          #define rUTXH0 (*(volatile unsigned*) 0x50000020)
          #define rURXH0 (*(volatile unsigned*) 0x50000024)
          #define rUBRDIV0 (*(volatile unsigned*) 0x50000028)
          int Main(){
          char buf;
          rULCON0 = 0xfff00;
          rULCON0 |= 0x3;
          rUCON0 = 0x0805;
          rUBRDIV0 = 26;
          while(1){
          if(rUTRSTAT0&0x1){
          buf = rURXH0;
          while(!(rUTRSTAT0&0x04));
          rUTXH0 = buf;
          }
          }
          return 0;
          }


          這是通過向串口發(fā)送數(shù)據(jù),根據(jù)發(fā)送的數(shù)據(jù)控制led哪個(gè)燈亮的程序。注意事項(xiàng)是:我使用的是串口調(diào)試助手,發(fā)送數(shù)據(jù)前首先要設(shè)置波特率為115200,否則沒有任何顯示。void Delay(unsigned int x);這句話要在Main函數(shù)內(nèi)聲明,在外面聲明就不好使,不知為什么。


          #define GPFCON (*(volatile unsigned*) 0x56000050)
          #define GPFDAT (*(volatile unsigned*) 0x56000054)
          #define GPFUP (*(volatile unsigned*) 0x56000058)
          #define ULCON0 (*(volatile unsigned*) 0x50000000)
          #define UCON0 (*(volatile unsigned*) 0x50000004)
          #define UTRSTAT0 (*(volatile unsigned*) 0x50000010)
          #define UTXH0 (*(volatile unsigned*) 0x50000020)
          #define URXH0 (*(volatile unsigned*) 0x50000024)
          #define UBRDIV0 (*(volatile unsigned*) 0x50000028)
          int Main(){
          void Delay(unsigned int x);
          char buf;
          GPFCON &= 0xc03f;
          GPFCON |= 0x1540;
          GPFUP &= 0x87;
          ULCON0 |= 0x3;
          UCON0 &= 0x0800;
          UCON0 |= 0x05;
          while(1){
          if(UTRSTAT0 & 0x1){
          buf = URXH0;
          while(!(UTRSTAT0 & 0x4));
          UTXH0 = buf;
          switch(buf){
          case 0x11:
          GPFDAT = 0xf7;
          Delay(100);
          break;
          case 0x22:
          GPFDAT = 0xef;
          Delay(100);
          break;
          case 0x33:
          GPFDAT = 0xdf;
          Delay(100);
          break;
          case 0x44:
          GPFDAT = 0xbf;
          Delay(100);
          break;
          }
          }
          }
          }
          void Delay(unsigned int x){
          int i,j,k;
          for(i = 0; i <= x; i++)
          for(j = 0; j <= 0xff; j++)
          for(k = 0; k <= 0xff; k++)
          ;
          }


          關(guān)鍵詞: S3C2440UART波特

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();