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

          新聞中心

          測試S3C2440的定時器

          作者: 時間:2016-11-20 來源:網(wǎng)絡(luò) 收藏

          本文引用地址:http://www.ex-cimer.com/article/201611/318931.htm
          1. /*******************************************
          2. *文件名稱:PWM.c
          3. *功能:測試s3c2440的PWM功能
          4. *作者:jianqi
          5. *版本:1.0
          6. **********************************************/
          7. #include"2440addr.h"http://包含2440相關(guān)寄存器的設(shè)置
          8. #include"def.h"
          9. #defineU32unsignedint
          10. //四個LED對應(yīng)GPB5.6.7.8。
          11. #defineLED15
          12. #defineLED26
          13. #defineLED37
          14. #defineLED48
          15. #defineBit(x)(1<
          16. #defineOutput(x)(1<<2*x)//將對應(yīng)IO置為輸出
          17. /*******************************************
          18. *名稱:Timer0_ISR
          19. *功能:Timer0中斷服務(wù)程序
          20. *入口參數(shù):無
          21. *出口參數(shù):無
          22. **********************************************/
          23. void__irqTimer0_ISR(void)
          24. {
          25. staticintcount=0;
          26. count++;
          27. rSRCPND=rSRCPND|(0x1<<10);
          28. rINTPND=rINTPND|(0x1<<10);//每隔2秒LED亮
          29. if(count%4==0)
          30. {
          31. rGPBDAT=~0x1e0;//LED全亮
          32. }
          33. elseif(count%4==1)
          34. {
          35. rGPBDAT=0x1e0;//LED全滅
          36. }
          37. }
          38. /*******************************************
          39. *名稱:Time0_init
          40. *功能:Timer0初始化
          41. *入口參數(shù):無
          42. *出口參數(shù):無
          43. **********************************************/
          44. voidTime0_init(void)
          45. {
          46. rTCFG0=249;//250分頻
          47. rTCFG1=0x02;//1/8分頻,25Khz
          48. rTCNTB0=12500;//定時0.5秒
          49. rTCON=(1<<1)|(1<<3);//更新TCNTB0,自動重載
          50. rTCON&=~(1<<1);//清除手動更新位
          51. }
          52. /*******************************************
          53. *名稱:IO_init
          54. *功能:B口初始化
          55. *入口參數(shù):無
          56. *出口參數(shù):無
          57. **********************************************/
          58. voidIO_init(void)
          59. {
          60. rGPBCON=Output(LED1)|Output(LED2)|Output(LED3)|Output(LED4);//LED的IO口置為輸出
          61. rGPBDAT=0xffff;//LED全部熄滅
          62. }
          63. /*******************************************
          64. *名稱:INT_init
          65. *功能:中斷初始化
          66. *入口參數(shù):無
          67. *出口參數(shù):無
          68. **********************************************/
          69. voidINT_init(void)
          70. {
          71. rSRCPND=rSRCPND|(0x1<<10);
          72. rINTPND=rINTPND|(0x1<<10);
          73. rINTMSK=~(0x1<<10);//打開Timer0中斷
          74. }
          75. /*******************************************
          76. *名稱:Main
          77. *功能:測試PWM功能
          78. *入口參數(shù):無
          79. *出口參數(shù):無
          80. **********************************************/
          81. voidMain(void)
          82. {
          83. IO_init();//初始化IO口
          84. Time0_init();//初始化Timer0
          85. INT_init();//初始化Timer0的中斷
          86. pISR_TIMER0=(U32)Timer0_ISR;//注冊Timer0中斷函數(shù)
          87. rTCON|=(1<<0);//開始TImer0
          88. while(1);
          89. {
          90. ;
          91. }
          92. }




          關(guān)鍵詞: S3C2440定時

          評論


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