標(biāo)題: 我手里有一款C8051f040單片機,誰能提供一份資料 求幫助 [打印本頁]

作者: 雪域孤寒    時間: 2019-4-4 15:01
標(biāo)題: 我手里有一款C8051f040單片機,誰能提供一份資料 求幫助
如題
作者: angmall    時間: 2019-4-18 23:00
C8051F040中文資料下載(共292頁pdf數(shù)據(jù)手冊)
http://www.torrancerestoration.com/bbs/dpj-120861-1.html


C8051F040串口通訊 IO口測試 流水燈閃爍燈等實例程序
C8051F040實例
單片機源程序如下:
  1. //------------------------------------------------------------------------------------
  2. // F04x_Blinky.c
  3. //------------------------------------------------------------------------------------
  4. // Copyright (C) 2007 Silicon Laboratories, Inc.
  5. //
  6. // AUTH: BD
  7. // DATE: 15 MAR 2002
  8. //
  9. // This program flashes the green LED on the C8051F040 target board about five times
  10. // a second using the interrupt handler for Timer3.
  11. // Target: C8051F04x
  12. //
  13. // Tool chain: KEIL Eval 'c'
  14. //

  15. //------------------------------------------------------------------------------------
  16. // Includes
  17. //------------------------------------------------------------------------------------
  18. #include <c8051f040.h>                    // SFR declarations

  19. //-----------------------------------------------------------------------------
  20. // 16-bit SFR Definitions for 'F04x
  21. //-----------------------------------------------------------------------------

  22. sfr16 RCAP3    = 0xCA;                 // Timer3 reload value
  23. sfr16 TMR3     = 0xCC;                 // Timer3 counter

  24. //------------------------------------------------------------------------------------
  25. // Global CONSTANTS
  26. //------------------------------------------------------------------------------------

  27. #define SYSCLK 3062500                    // approximate SYSCLK frequency in Hz

  28. sbit  LED = P1^6;                         // green LED: '1' = ON; '0' = OFF

  29. //------------------------------------------------------------------------------------
  30. // Function PROTOTYPES
  31. //------------------------------------------------------------------------------------
  32. void PORT_Init (void);
  33. void Timer3_Init (int counts);
  34. void Timer3_ISR (void);

  35. //------------------------------------------------------------------------------------
  36. // MAIN Routine
  37. //------------------------------------------------------------------------------------
  38. void main (void) {

  39.    // disable watchdog timer
  40.    WDTCN = 0xde;
  41.    WDTCN = 0xad;

  42.    SFRPAGE = CONFIG_PAGE;                 // Switch to configuration page
  43.    PORT_Init ();

  44.    SFRPAGE = TMR3_PAGE;                   // Switch to Timer 3 page
  45.    Timer3_Init (SYSCLK / 12 / 10);        // Init Timer3 to generate interrupts
  46.                                           // at a 10 Hz rate.
  47.    EA = 1;                                                                                        // enable global interrupts

  48.    SFRPAGE = LEGACY_PAGE;                 // Page to sit in for now

  49.    while (1) {                            // spin forever

  50.    }
  51. }

  52. //------------------------------------------------------------------------------------
  53. // PORT_Init
  54. //------------------------------------------------------------------------------------
  55. //
  56. // Configure the Crossbar and GPIO ports
  57. //
  58. void PORT_Init (void)
  59. {
  60.    XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
  61.    P1MDOUT |= 0x40;                    // enable P1.6 (LED) as push-pull output
  62. }

  63. //------------------------------------------------------------------------------------
  64. // Timer3_Init
  65. //------------------------------------------------------------------------------------
  66. //
  67. // Configure Timer3 to auto-reload and generate an interrupt at interval
  68. // specified by <counts> using SYSCLK/12 as its time base.
  69. //
  70. //
  71. void Timer3_Init (int counts)
  72. {
  73.    TMR3CN = 0x00;                      // Stop Timer3; Clear TF3;
  74.                                        // use SYSCLK/12 as timebase
  75.    RCAP3   = -counts;                  // Init reload values
  76.    TMR3    = 0xffff;                   // set to reload immediately
  77.    EIE2   |= 0x01;                     // enable Timer3 interrupts
  78.    TR3 = 1;                            // start Timer3
  79. }

  80. //------------------------------------------------------------------------------------
  81. // Interrupt Service Routines
  82. //------------------------------------------------------------------------------------

  83. //------------------------------------------------------------------------------------
  84. // Timer3_ISR
  85. //------------------------------------------------------------------------------------
  86. // This routine changes the state of the LED whenever Timer3 overflows.
  87. //
  88. // NOTE: The SFRPAGE register will automatically be switched to the Timer 3 Page
  89. // When an interrupt occurs.  SFRPAGE will return to its previous setting on exit
  90. // from this routine.
  91. //
  92. void Timer3_ISR (void) interrupt 14
  93. {
  94.    TF3 = 0;                               // clear TF3
  95.    LED = ~LED;                            // change state of LED
  96. }
復(fù)制代碼



C8051F04x代碼全部
1、ADC,模數(shù)轉(zhuǎn)換
2、Blinky, LED閃爍燈
3、Comparators,比較器
4、DAC,數(shù)模轉(zhuǎn)換
5、HeadFiles
6、Interrupts中斷
7、晶振選擇
8、PCA
9、端口處理
10、SMBUS
11、SPI總線
12、定時器
13、串口UARTS
14、看門狗WatchDog


C8051F040代碼集




C8051F04x.zip

163.76 KB, 下載次數(shù): 14

C8051F040代碼集






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1