51 microcontroller learning: external interrupt 1 experiment

Publisher:HarmoniousCharmLatest update time:2023-07-19 Source: zhihu Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Experiment name: External interrupt 1 Experiment
wiring description:
Experiment phenomenon: After downloading the program, pressing the K4 key can control the D1 indicator light to turn on and off.
Notes:
******************* *************************************************** ******************/
#include "reg52.h"

typedef unsigned int u16; //Redefine the system default data type
typedef unsigned char u8;

//Define LED1 pin
sbit LED1=P2^0;

//Define independent button K4 control pin
sbit KEY4=P3^3;


/****************************************************** ****************************
* Function name: delay_10us
* Function function: Delay function, when ten_us=1, the delay is approximately 10us
* Input: ten_us
* Output: None
**************************************** ***************************************/
void delay_10us(u16 ten_us)
{
while(ten_us --);
}

/****************************************************** ******************************
* Function name: exti1_init
* Function function: External interrupt 1 configuration function
* Input: None
* Output : none
************************************************ *****************************/
void exti1_init(void)
{
IT1=1;//Edge trigger mode ( Falling edge)
EX1=1;//Turn on the interrupt enablement of INT1
EA=1;//Turn on the total interrupt
}

/****************************************************** ******************************
* Function name: main
* Function function: main function
* Input: None
* Output: None
* *************************************************** ******************************/
void main()
{
exti1_init();//External interrupt 1 configuration

while(1)
{

}
}

void exti1() interrupt 2 //External interrupt 1 interrupt function
{
delay_10us(1000);//Destroy
if(KEY4==0)//Determine again whether the K4 key is pressed
LED1=!LED1;//LED1 status flip
}



Reference address:51 microcontroller learning: external interrupt 1 experiment

Previous article:51 microcontroller learning: timer 0 experiment
Next article:51 microcontroller learning: external interrupt 0 experiment

Recommended posts

zd test zd test 1
eric_wang Analog electronics
USB network port module test based on TI Sitara Cortex-A8
USBnetworkportmoduletest TheUSBnetworkportmoduleusedinthiscaseisMicrochip'sEVB-LAN9500A-LC,whichcanbeusedtoexpandthenetworkportoftheevaluationboard.StarttheevaluationboardandconnecttheUSBnetworkportmodu
Tronlong小分队 ARM Technology
Technical Article: Reliable Power-Up and Power-Down Sequencing
Today’selectronicapplicationsoftenrequiremorethanone5Vor3.3Vsupplyvoltage.Ten,20,ormorevoltagesarenotuncommon.Inaddition,therearevoltagedomainsthathavethesamevoltagelevelbutmustbegeneratedasseparatedomains—th
okhxyyo Power technology
Study the signal strength of the RF coil
RFcoiltechnologyisubiquitousthroughouttheworldandisamajorcomponentoftechnologyrangingfrommedicaldevicestowirelessconnectivity.Itisimportanttoensurethatthecoilscontainedinthesedevicesareproperlytransmittinginforma
btty038 RF/Wirelessly
[National Technology Low Power Series N32L43x Review] 08. Software and Hardware I2C Driver 1.5-inch 16-color grayscale OLED display
Overview TheNationalN32L43xseriesMCUhasa2-wayhardwareI2Cinterface,whichprovidesmulti-hostfunctionalityandcontrolsallI2Cbus-specifictiming,protocols,arbitration,andtiming.Itsupportsmultiplecommunicationmodes(upto1M
xld0932 Domestic Chip Exchange
Discussion on Deep Learning Frameworks
Theopensourceecosystemisverycomplete.Well-knowndeeplearning-relatedopensourceframeworksincludecaffe,tensorflow,pytorch/caffe2,keras,mxnet,paddldpaddle,theano,cntk,deeplearning4j,matconvnet,etc.Inaddition,therearenichef
ljg2np Programming Basics
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号