找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1331|回复: 1
收起左侧

我手里有一款C8051f040单片机,谁能提供一份资料 求帮助

[复制链接]
ID:504834 发表于 2019-4-4 15:01 | 显示全部楼层 |阅读模式
如题
回复

使用道具 举报

ID:155507 发表于 2019-4-18 23:00 | 显示全部楼层
C8051F040中文资料下载(共292页pdf数据手册)
http://www.51hei.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. }
复制代码



C8051F04x代码全部
1、ADC,模数转换
2、Blinky, LED闪烁灯
3、Comparators,比较器
4、DAC,数模转换
5、HeadFiles
6、Interrupts中断
7、晶振选择
8、PCA
9、端口处理
10、SMBUS
11、SPI总线
12、定时器
13、串口UARTS
14、看门狗WatchDog


C8051F040代码集




C8051F04x.zip

163.76 KB, 下载次数: 14

C8051F040代码集

评分

参与人数 1黑币 +50 收起 理由
admin + 50 回帖助人的奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表