打印
[活动]

EFM8BB1测评——闪灯

[复制链接]
563|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Cjy_JDxy|  楼主 | 2019-11-29 20:03 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
fm, TI, LED, se, ic
以前没用过silabs公司的芯片,C8051没用过,小壁虎也没用过。
今天有机会了,先搞个闪灯。开发环境simplicity studio v4
代码:
#include <SI_EFM8SB2_Register_Enums.h>                // SFR declarations
#include "InitDevice.h"

SI_SBIT(LED, SFR_P1, 4);   // LED
SI_SBIT(S1, SFR_P0, 2);                                   // BTN0

#define SYSCLK      24500000/8         // Clock speed in Hz (default)

#define SW_PRESSED           0
#define SW_NOT_PRESSED       1

#define LED_ON               0
#define LED_OFF              1
//-----------------------------------------------------------------------------
// SiLabs_Startup() Routine
// ----------------------------------------------------------------------------
// This function is called immediately after reset, before the initialization
// code is run in SILABS_STARTUP.A51 (which runs before main() ). This is a
// useful place to disable the watchdog timer, which is enable by default
// and may trigger before main() in some instances.
//-----------------------------------------------------------------------------
void SiLabs_Startup (void)
{
  // Disable the watchdog here
}

//-----------------------------------------------------------------------------
// main() Routine
// ----------------------------------------------------------------------------
// Note: the software watchdog timer is not disabled by default in this
// example, so a long-running program will reset periodically unless
// the timer is disabled or your program periodically writes to it.
//
// Review the "Watchdog Timer" section under the part family's datasheet
// for details. To find the datasheet, select your part in the
// Simplicity Launcher and click on "Data Sheet".
//-----------------------------------------------------------------------------
int main (void)
{
        unsigned int i;
        enter_DefaultMode_from_RESET();
        while (1)
        {
                LED = LED_OFF;
                for(i=0;i<20000;i++);
                LED = LED_ON;
                for(i=0;i<20000;i++);
        }                             // Spin forever
}

效果图:




使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:绿水本无忧因风皱面,青山原不老为雪白头。

553

主题

3530

帖子

19

粉丝