你这么一说,又仔细看了一眼开发板。
真的有点紫铜的颜色啊
点灯继续:
在官方例子上进行修改,添加管脚定义,添加一个delay函数,具体如下:
//----------------------------------------------------------------------------- // EFM8BB52_Blinky.c //----------------------------------------------------------------------------- // Copyright 2021 Silicon Laboratories, Inc. // http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt // // Program Description: // // This program flashes the red/green/blue LED on the EFM8BB52 PK board about // five times a second using the interrupt handler for Timer2. // // Resources: // SYSCLK - 24.5 MHz HFOSC0 / 8 // Timer2 - 5 Hz interrupt // P1.4 - LED0 // //----------------------------------------------------------------------------- // How To Test: EFM8BB52 Explorer Kit //----------------------------------------------------------------------------- // 1) Connect the EFM8BB52 Explorer Kit to a PC using a mini USB cable. // 2) Compile and download code to the EFM8BB52 Explorer Kit board. // In Simplicity Studio IDE, select Run -> Debug from the menu bar, // click the Debug button in the quick menu, or press F11. // 3) Run the code. // In Simplicity Studio IDE, select Run -> Resume from the menu bar, // click the Resume button in the quick menu, or press F8. // 4) The LED0 should blink at approximately 5 Hz. // // Target: EFM8BB52 // Tool chain: Generic // // Release 0.1 (RN) // - Initial Revision // //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <SI_EFM8BB52_Register_Enums.h> #include <InitDevice.h> #include <SI_EFM8BB52_Register_Enums.h> //----------------------------------------------------------------------------- // Pin Definitions //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // 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 } SI_SBIT(LED0, SFR_P1, 4);// 这个地方定义led0为p1.4,直接命名为led0 void delay(unsigned int xms) //简单做个delay //xms代表需要延时的毫秒数 { unsigned int x,y; for(x=xms;x>0;x--) for(y=110;y>0;y--); } //----------------------------------------------------------------------------- // Main Routine //----------------------------------------------------------------------------- void main (void) { enter_DefaultMode_from_RESET(); //IE_EA = 1; // Enable global interrupts while (1) { LED0 = !LED0; delay(1000); } } // Spin forever
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |