CC2530 External Interrupt Controlled LED Light Switch

Publisher:VelvetSoulLatest update time:2022-10-13 Source: csdnKeywords:CC2530 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Experimental requirements

Code

#include "ioCC2530.h"

 

#define D3 P1_0

#define D4 P1_1

#define D5 P1_3

#define D6 P1_4

 

//delay function

void Delay(unsigned int t)

{

  while(t--);

}

 

//Port initialization function

void Init_Prot()

{

//Configure the engine with 4 LED lights

  //Select port function

  P1SEL &=~0x1B;//Set general io port

  //Configure the direction of the port

  P1DIR |=0x1B;

  //Turn off the LED light

  P1 &=~0x1B;

}

 

//Initialization of external interrupt port 1

void Init_INTP1()

{

  //Clear the external interrupt flag bit

  P1IFG = 0x00; 

  //Enable P1 port group interrupt

  IEN2 |=0x10;

  //Enable P1 pin interrupt P1_2

  P1IEN |=0x04; 

  //Select the trigger type of the external interrupt signal

  PICTL |=0x02;

  //Turn on and enable the total interrupt

  EA = 1;

}

 

 

#pragma vector = P1INT_VECTOR //Start statement

//interrupt service function

__interrupt void Service_INTP1()

{

  //Handle external interrupt

  if((P1IFG &0x04)==0x04)

  {

    D5 =~D5;

  }

  

  //Clear the index of the register to zero

  P1IFG = 0x00; //Clear the pin first

  P1IF = 0x00; //Clear the port group again

}

 

 

void main(void)

{

  //Port initialization

  Init_Prot();

  Init_INTP1();

  while(1)

  {

    D4 = 1;

    Delay(60000);

    Delay(60000);

    D4 = 0;

    Delay(60000);

    Delay(60000);

  }

}

Keywords:CC2530 Reference address:CC2530 External Interrupt Controlled LED Light Switch

Previous article:CC2530 second flash light based on timer 1 touch mode
Next article:CC2530 button controls the running and pausing of the marquee

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号