久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 5359|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

c8051f320單片機(jī)15個(gè)例程源碼(都是一些常用功能)

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
c8051單片機(jī)例程源碼


單片機(jī)源程序如下:
  1. //-----------------------------------------------------------------------------
  2. // F32x_External_Interrupts.c
  3. //-----------------------------------------------------------------------------
  4. // Copyright 2007 Silicon Laboratories, Inc.

  5. // Program Description:
  6. //
  7. // This software shows the necessary configuration to use External Interrupt 0
  8. // (/INT0) or External Interrupt 1 (/INT1) as an interrupt source.  The code
  9. // executes the initialization routines and then spins in an infinite while()
  10. // loop.  If the button on P1.6 (on the target board) is pressed, then the
  11. // edge-triggered /INT0 input on P0.0 will cause an interrupt and toggle the
  12. // LED.
  13. //
  14. // Pinout:
  15. //
  16. // P0.0 - /INT0
  17. // P0.1 - /INT1
  18. //
  19. // P2.0 - SW1 (Switch 1)
  20. // P2.1 - SW2 (Switch 2)
  21. // P2.2 - LED1
  22. // P2.3 - LED2
  23. //
  24. // How To Test:
  25. //
  26. // 1) Compile and download code to a 'F32x target board.
  27. // 2) On the target board, connect P2.0_SW and P2.1_SW signals on J3 to P0.0
  28. //    for /INT0 and P0.1 for /INT1.
  29. // 3) Press the switches.  Every time a switch is pressed, the P2.2 or P2.3
  30. //    LED should toggle.
  31. //
  32. // Target:         C8051F32x
  33. // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  34. // Command Line:   None
  35. //
  36. //
  37. // Release 1.0
  38. //    -Initial Revision (TP)
  39. //    -14 JUN 2007
  40. //

  41. //-----------------------------------------------------------------------------
  42. // Include Files
  43. //-----------------------------------------------------------------------------

  44. #include <C8051F320.h>

  45. //-----------------------------------------------------------------------------
  46. // Global Constants
  47. //-----------------------------------------------------------------------------

  48. #define SYSCLK             12000000    // Clock speed in Hz

  49. sbit SW1 = P2^0;                       // Push-button switch on board
  50. sbit SW2 = P2^1;                       // Push-button switch on board
  51. sbit LED1 = P2^2;                      // Green LED
  52. sbit LED2 = P2^3;                      // Green LED

  53. //-----------------------------------------------------------------------------
  54. // Function Prototypes
  55. //-----------------------------------------------------------------------------

  56. void Oscillator_Init (void);           // Configure the system clock
  57. void Port_Init (void);                 // Configure the Crossbar and GPIO
  58. void Ext_Interrupt_Init (void);        // Configure External Interrupts (/INT0
  59.                                        // and /INT1)

  60. //-----------------------------------------------------------------------------
  61. // MAIN Routine
  62. //-----------------------------------------------------------------------------
  63. void main (void)
  64. {
  65.    PCA0MD &= ~0x40;                    // Disable Watchdog timer

  66.    Oscillator_Init();                  // Initialize the system clock
  67.    Port_Init ();                       // Initialize crossbar and GPIO
  68.    Ext_Interrupt_Init();               // Initialize External Interrupts

  69.    EA = 1;

  70.    while(1);                           // Infinite while loop waiting for
  71.                                        // an interrupt from /INT0 or /INT1
  72. }

  73. //-----------------------------------------------------------------------------
  74. // Initialization Subroutines
  75. //-----------------------------------------------------------------------------

  76. //-----------------------------------------------------------------------------
  77. // Oscillator_Init
  78. //-----------------------------------------------------------------------------
  79. //
  80. // Return Value : None
  81. // Parameters   : None
  82. //
  83. // This routine initializes the system clock to use the precision internal
  84. // oscillator as its clock source.
  85. //-----------------------------------------------------------------------------
  86. void Oscillator_Init (void)
  87. {
  88.    OSCICN = 0x83;                      // Set internal oscillator to run
  89.                                        // at its maximum frequency
  90. }

  91. //-----------------------------------------------------------------------------
  92. // Port_Init
  93. //-----------------------------------------------------------------------------
  94. //
  95. // Return Value : None
  96. // Parameters   : None
  97. //
  98. // This function configures the crossbar and GPIO ports.
  99. //
  100. // Pinout:
  101. //
  102. // P0.0 - digital        open-drain         /INT0
  103. // P0.1 - digital        open-drain         /INT1
  104. //
  105. // P2.0 - digital        open-drain         SW1 (Switch 1)
  106. // P2.1 - digital        open-drain         SW2 (Switch 2)
  107. // P2.2 - digital        push-pull         LED1
  108. // P2.3 - digital        push-pull        LED2
  109. //
  110. //-----------------------------------------------------------------------------
  111. void Port_Init (void)
  112. {
  113.    XBR1     = 0x40;                    // Enable crossbar and weak pullups

  114.    P2MDOUT  = 0x0C;                    // LED1 and LED2 are push-pull outputs
  115. }

  116. //-----------------------------------------------------------------------------
  117. // Ext_Interrupt_Init
  118. //-----------------------------------------------------------------------------
  119. //
  120. // Return Value : None
  121. // Parameters   : None
  122. //
  123. // This function configures and enables /INT0 and /INT1 (External Interrupts)
  124. // as negative edge-triggered.
  125. //
  126. //-----------------------------------------------------------------------------
  127. void Ext_Interrupt_Init (void)
  128. {
  129.    TCON = 0x05;                        // /INT 0 and /INT 1 are edge triggered

  130.    IT01CF = 0x10;                      // /INT0 active low; /INT0 on P0.0;
  131.                                        // /INT1 active low; /INT1 on P0.1

  132.    EX0 = 1;                            // Enable /INT0 interrupts
  133.    EX1 = 1;                            // Enable /INT1 interrupts
  134. }

  135. //-----------------------------------------------------------------------------
  136. // Interrupt Service Routines
  137. //-----------------------------------------------------------------------------

  138. //-----------------------------------------------------------------------------
  139. // /INT0 ISR
  140. //-----------------------------------------------------------------------------
  141. //
  142. // Whenever a negative edge appears on P0.0, LED1 is toggled.
  143. // The interrupt pending flag is automatically cleared by vectoring to the ISR
  144. //
  145. //-----------------------------------------------------------------------------
  146. ……………………

  147. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
320-15個(gè)例程.zip (743.48 KB, 下載次數(shù): 135)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:64765 發(fā)表于 2019-9-16 15:27 | 只看該作者
關(guān)于C8051F系列單片機(jī)的例程代碼可到 https://github.com下載---C8051F-master.zip
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 欧美成人精品在线观看 | 日韩精品在线免费观看视频 | 久久综合伊人 | 亚洲精品久久久久中文字幕欢迎你 | 男女羞羞的网站 | 免费观看黄a一级视频 | 成人免费视频网站在线观看 | 美女黄视频网站 | 欧洲妇女成人淫片aaa视频 | 黄a免费网络 | 亚洲精品一区二区 | 日韩av在线播 | 在线观看黄免费 | 黄色免费在线观看网址 | 蜜桃视频在线观看免费视频网站www | 午夜精品一区二区三区免费视频 | 免费看黄视频网站 | 国产精品毛片无码 | 日韩免费视频 | 久久免费精品 | 国产专区视频 | 久久久久网站 | 亚洲国产精品一区二区第一页 | aaa大片免费观看 | 日本手机看片 | 国产成人精品午夜视频免费 | 伊人伊成久久人综合网站 | 九九九精品视频 | 日本成人免费网站 | 亚洲+变态+欧美+另类+精品 | 久久av一区二区三区 | 超碰成人免费 | 久久天堂网 | 日韩1区2区| 久久国产综合 | 欧美精品久久久 | 91成人在线 | 亚洲欧美在线一区 | 男女网站免费观看 | 成年人精品视频在线观看 | 美女福利网站 |