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

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

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 5429|回復(fù): 1
收起左側(cè)

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

[復(fù)制鏈接]
ID:378646 發(fā)表于 2018-7-24 19:27 | 顯示全部樓層 |閱讀模式
c8051單片機(jī)例程源碼
0.png

單片機(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)分

回復(fù)

使用道具 舉報(bào)

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ù) 返回頂部 返回列表
主站蜘蛛池模板: 精品国产乱码久久久久久1区2区 | 成人午夜在线 | 国产精品久久久爽爽爽麻豆色哟哟 | 四虎国产 | 欧美日韩精品在线一区 | 91精品国产91久久久 | 日本一区二区不卡 | 精品视频一区二区三区在线观看 | 6080亚洲精品一区二区 | 国产高清在线观看 | 欧美区日韩区 | 精品欧美一区二区三区久久久 | 91久久精品一区二区二区 | 天天看天天干 | 中文精品久久 | 久久久久久久久久爱 | 成人精品视频在线观看 | 狠狠躁夜夜躁人人爽天天高潮 | www国产成人免费观看视频,深夜成人网 | 国产精品成人国产乱 | 最近最新中文字幕 | 黄免费看 | 国色天香综合网 | 欧美一级片中文字幕 | 久久精品欧美一区二区三区麻豆 | 精品欧美一区二区精品久久久 | 日韩国产欧美 | 老牛影视av一区二区在线观看 | 奇米超碰在线 | 人人性人人性碰国产 | 91免费高清| 欧美成人一区二免费视频软件 | 久久99精品久久久久久 | 91久久北条麻妃一区二区三区 | 日韩欧美不卡 | 福利视频网址 | 亚洲男人天堂 | 国产精品一区二区久久 | 极品久久| av国产精品毛片一区二区小说 | 欧美午夜精品 |