以前没用过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
}
效果图:
|