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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > GNU ARM匯編--(七)s3c2440的串口控制

          GNU ARM匯編--(七)s3c2440的串口控制

          作者: 時(shí)間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
        1. .global_main
        2. _main:
        3. ldrr0,=GPBCON
        4. ldrr1,=0x15400
        5. strr1,[r0]
        6. ldrr2,=GPBDAT
        7. blclock_setup
        8. bluart_init
        9. bldelay
        10. ldrlr,=loop
        11. @bluart_testdd
        12. ldrpc,_uart_test
        13. _uart_test:.worduart_test
        14. loop:
        15. bloop@死循環(huán)
        16. ledloop:
        17. ldrr1,=0x1c0
        18. strr1,[r2]
        19. bldelay
        20. ldrr1,=0x1a0
        21. strr1,[r2]
        22. bldelay
        23. ldrr1,=0x160
        24. strr1,[r2]
        25. bldelay
        26. ldrr1,=0x0e0
        27. strr1,[r2]
        28. bldelay
        29. bledloop
        30. clock_setup:
        31. ldrr0,=LOCKTIME
        32. ldrr1,=0xffffffff
        33. strr1,[r0]
        34. ldrr0,=CLKDIVN
        35. ldrr1,=(DIVN_UPLL<<3)|(HDIVN<<1)|(PDIVN<<0)
        36. strr1,[r0]
        37. ldrr0,=UPLLCON
        38. ldrr1,=(U_MDIV<<12)|(U_PDIV<<4)|(U_SDIV<<0)@Fin=12MUPLL=48M
        39. strr1,[r0]
        40. nop
        41. nop
        42. nop
        43. nop
        44. nop
        45. nop
        46. nop
        47. ldrr0,=MPLLCON
        48. ldrr1,=(M_MDIV<<12)|(M_PDIV<<4)|(M_SDIV<<0)@Fin=12MFCLK=400M
        49. strr1,[r0]
        50. movpc,lr
        51. uart_init:
        52. ldrr0,=GPHCON
        53. ldrr1,=0x2aaaa@配置GPIO復(fù)用規(guī)則為串口
        54. strr1,[r0]
        55. ldrr0,=ULCON0
        56. ldrr1,=(IR_MODE<<6)|(Parity_Mode<<3)|(Num_of_stop_bit<<2)|(Word_length<<0)@
        57. strr1,[r0]
        58. ldrr0,=UCON0
        59. ldrr1,=(FCLK_Div<<12)|(Clk_select<<10)|(Tx_Int_Type<<9)|(Rx_Int_Type<<8)|(Rx_Timeout<<7)|(Rx_Error_Stat_Int<<6)|(Loopback_Mode<<5)|(Break_Sig<<4)|(Tx_Mode<<2)|(Rx_Mode<<0)
        60. strr1,[r0]
        61. ldrr0,=UFCON0
        62. ldrr1,=(Tx_FIFO_Trig_Level<<6)|(Rx_FIFO_Trig_Level<<4)|(Tx_FIFO_Reset<<2)|(Rx_FIFO_Reset<<1)|(FIFO_Enable<<0)@
        63. strr1,[r0]
        64. ldrr0,=UBRDIV0
        65. ldrr1,=(UBRDIV<<0)
        66. strr1,[r0]
        67. movpc,lr
        68. delay:
        69. @ldrr3,=0x4ffffff
        70. ldrr3,=0xfffff
        71. delay1:
        72. subr3,r3,#1
        73. cmpr3,#0x0
        74. bnedelay1
        75. movpc,lr

        76. UART的測試代碼用C寫的:

          本文引用地址:http://www.ex-cimer.com/article/201611/321724.htm

          uart_test.c:

          [cpp]view plaincopy
          1. #include"uart_test.h"
          2. charuart_GetByte(void)
          3. {
          4. while(!(rUTRSTAT0&0x1));//WaituntilTHRisempty.
          5. returnRdURXH0();
          6. }
          7. voiduart_GetString(char*pt)
          8. {
          9. while(*pt)
          10. uart_GetByte();
          11. }
          12. voiduart_SendByte(intdata)
          13. {
          14. if(data==)
          15. {
          16. while(!(rUTRSTAT0&0x2));
          17. WrUTXH0();
          18. }
          19. while(!(rUTRSTAT0&0x2));//WaituntilTHRisempty.
          20. WrUTXH0(data);
          21. }
          22. //====================================================================
          23. voiduart_SendString(char*pt)
          24. {
          25. while(*pt)
          26. uart_SendByte(*pt++);
          27. }
          28. voiduart_test(void)
          29. {
          30. charstr[20]="helloworld";
          31. inta=97;
          32. //while(1)
          33. //uart_SendByte(a);
          34. uart_SendString(str);
          35. chars=uart_GetByte();
          36. //if(s==a)
          37. if(s==97)
          38. rGPBDAT=0x1c0;
          39. //uart_SendByte(a);
          40. //uart_SendByte(97);
          41. //uart_SendByte(a);
          42. uart_SendByte((int)s);
          43. uart_SendByte((int)s);
          44. }
          uart_test.h:

          [cpp]view plaincopy
          1. //#defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000023)=(unsignedchar)(ch)
          2. #defineWrUTXH0(ch)(*(volatileunsignedchar*)0x50000020)=(unsignedchar)(ch)
          3. #defineRdURXH0()(*(volatileunsignedchar*)0x50000024)
          4. #definerUTRSTAT0(*(volatileunsigned*)0x50000010)//UART0Tx/Rxstatus
          5. #definerGPBDAT(*(volatileunsigned*)0x56000014)


          到此,使用串口的輪循模式,可以實(shí)現(xiàn)串口的正常收發(fā)功能了~~

          中斷模式還沒寫,這個(gè)等到后面全面研究uboot的時(shí)候再回頭看,uboot用哪種模式,應(yīng)該就說明那種方式好,到時(shí)侯再實(shí)現(xiàn)吧


          上一頁 1 2 3 下一頁

          關(guān)鍵詞: ARM匯編s3c2440串口控

          評論


          相關(guān)推薦

          技術(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); })();