1. Light the first light

Source: Internet
Author: User

I:\CC2540 Development \AMOMCU-CC254X Development Kit Data-May 2014 \4. Primary basic experiment -11.30\4. Primary basic Experiment \1.led flashing _ Running Lights \test

Connect the Cc-debug to the Development Board, the power cord and the data cable (before the user manual is finished)

Click Xxx.ewp to open in IAR

Click on the green arrow to enter the debug mode, you need to press one step or direct step over button to make the program run directly

Its code is similar to 51, and the only difference is in the 53rd line, with the cc2540 port definition (seemingly enabled).

1 /****************************************************************************2 * File name: main.c3 * Author: Amo [www.amoMcu.com single chip microcomputer]4 * Revision: 2014-04-085 * Version: 1.06 * Description: Operation IO port control 4 LED Lights allbright and all out, flashing, running lights7 ****************************************************************************/8#include <ioCC2540.h>9 Tentypedef unsignedCharUchar; Onetypedef unsignedint  UINT; A  - #defineLED1 P1_0//define the P1.0 port as the LED1 control end - #defineLED2 p1_1//define the P1.1 port as the LED2 control end the #defineLED3 p1_4//define the P1.4 port as the LED3 control end - #defineLED4 P0_1//define the P0.1 port as the LED4 control end -  -  + /**************************************************************************** - * Name: delayms () + * Function: Delay in milliseconds, default to 16M when system clock is not configured (very accurate with oscilloscope measurement) A * Entry parameters: msec delay parameter, the higher the value, the longer the delay at * Export parameters: None - ****************************************************************************/ - voidDelayms (UINTmsec) - {  -     UINTi,j; -      in      for(i=0; i<msec; i++) -          for(j=0; j<535; J + +); to } +  - /**************************************************************************** the * Name: Ledonoroff () * * Function: lights or turns off all LED lights. $ * Inlet parameter: Mode is 1 o'clock LED light mode for 0 o'clock LED light off, common cathodePanax Notoginseng * Export parameters: None - ****************************************************************************/ the voidLedonoroff (uchar mode) + { ALED1 =mode; theLED2 =mode; +LED3 =mode; -LED4 =mode; $ } $  - /**************************************************************************** - * Name: initled () the * Function: Set the corresponding IO port of the LED lamp - * Entry parameters: NoneWuyi * Export parameters: None the ****************************************************************************/  53   void  initled (void  )  54  { 0x13 ; // p1.0, P1.1, P1.4 are defined as output       56  p0dir |= 0x02 ; // p0.1 is defined as output       57  Ledonoroff (0 ); //  58     -  - /**************************************************************************** A * Program Entry function + ****************************************************************************/ the voidMainvoid) - { $ Uchar i; the      theInitled ();//setting LED light related IO ports the      the      while(1)//dead Loop -     {   inLED1 =! LED1;//running lights, when the LED is off when initialized, is lit after execution theDelayms ( $);  theLED2 =!LED2;  AboutDelayms ( $);  theLED3 =!LED3;  theDelayms ( $);  theLED4 =!LED4;  +Delayms ( $);  -LED4 =!LED4;  theDelayms ( $); BayiLED3 =!LED3;  theDelayms ( $);  theLED2 =!LED2;  -Delayms ( $);  -LED1 =!LED1;  theDelayms ( $); the          the          for(i=0; i<2; i++)//all Lights blink 2 times the         { -Ledonoroff (0);//turn off all LED lights theDelayms ( $); theLedonoroff (1);//turn on all LED lights theDelayms ( $);94         } the          theLedonoroff (0);//make all LED lights off state theDelayms ( -);98     } About}

Links: Http://pan.baidu.com/s/1jG2CYaU

1. Light the first light

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.