TI CC2530 Basic Experiment (ordinary GPIO operation--click the button to light the light)

Source: Internet
Author: User

For CC2530 Gpio Basics, General Gpio operation about registers, IAR Embedded Workbench IDE software use: TI CC2530 Basic Experiment (ordinary GPIO operation-Light LED)

Schematic diagram of the circuit:


Analysis : You need to press the button to light the light, and do not use the interrupt mode, that is, we need to monitor whether the press is pressed (P0_4 is low, high-level means release).

Settings :

    • Lamp LED1 corresponding P1_0 pin for normal I/O, direction output
    • Key S1 corresponding P0_4 pin for normal I/O, direction input
program
/************************************** * Basic Experiment just add the following header file to *************************************/#include < iocc2530.h>/*********************************** * Program Description: Press the button to light the light **********************************/#define LED1 p1_0#define KEY1 p0_4/*********************************** * Function Description: Initialize LED1 **********************************/  void Led1init (void) {P1sel &= ~0x01;   function: normal I/O p1dir |= 0x01;        Direction: Output LED1 = 1; Make it out of State}/*********************************** * Function Description: Initialize key S1 **********************************/void Key1init (  void) {P0sel &= ~0x10;   function: normal I/O p0dir &= ~0x10; Direction: Input}/*********************************** * Function Description: Millisecond delay function **********************************/void delayms (  unsigned int ms) {unsigned int i,j;  for (i = ms, I > 0; i--) {for (j = 587; j > 0; j--); }}/*********************************** * Function Description: Scans the status of KEY1 and repairs LED1 **********************************/void Key1scan ( void) {if (0 = = KEY1)//means pressing {LED1 = 0;//low-level to make it leD1 Bright delayms (10);//Shake for (; 1 = = KEY1;)//Determine whether to loosen {LED1 = 1;//give high level to make it LED1 bright}}}void main () {led1init ();    Key1init ();  for (;;)  {Key1scan (); }}

Note: Each creation of a new project will be configured IAR (to do the basic experiment), TI CC2530 Basic Experiment (ordinary GPIO operation-led light) also has IAR related configuration steps


TI CC2530 Basic Experiment (ordinary GPIO operation--click the button to light the 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.