C51 INT0 interrupt program

Publisher:牟牟的侬Latest update time:2016-10-14 Source: eefocusKeywords:C51  INT0 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//INT0 interrupt program

#include
void delay(unsigned int x);

main()
{
  IT0=1; //Falling edge trigger

  EX0=1; //Open INT0 interrupt

  EA=1;
  P1=0xff;
  while(1)
  { }
}

void int0() interrupt 0
{
    IT0=0; //disable interrupt,
    P1=~P1;
    delay(20000); //delay
    IT0=1; //enable interrupt   
}

void delay(unsigned int x) //延时
{
  unsigned int i;
  for(i=0;i     {}
}

Keywords:C51  INT0 Reference address:C51 INT0 interrupt program

Previous article:c51 parity bit application
Next article:C51 timer to measure pulse width

Recommended ReadingLatest update time:2024-11-16 15:43

c51: Function
/* char cabs(char val); // calculate the absolute value of val    int abs(int val); long labs(long val); float fabs(float val); float sqrt(float val);    float exp(float val); float log(float val); float log10(floatextefn floatl0510〔float val); float sin(flaot val); float cos(flaot val); float tan(flaot val)
[Microcontroller]
C51 DS1302 chip + lcd12864 display time
1. Schematic 1302 chip part LCD12864 part 2. Code part config.h #ifndef __CONFIG_H #define __CONFIG_H #include reg51.h #include "lcd12864.h" #include "intrins.h"  #define uchar unsigned char #define uint unsigned int #endif  lcd12864.c #include "lcd12864.h" void lcdinit(void) //Initialize LCD  {     write(0,0
[Microcontroller]
C51 DS1302 chip + lcd12864 display time
Real-time clock DS1302 reading and writing program (C51)
//Open DS1302 void TimeSpiOpen(void) { TIMECLK = 0; TIMERST = 0; //Disable DS1302 TIMEIO = 1; //Release data bus TIMERST = 1; //Enable DS1302 } //Close DS1302 void TimeSpiClose(void) { TIMERST = 0;//Disable DS1302 TIMEIO = 1;//Release data bus TIMECLK = 1; } //Read and write DS1302 unsigned char TimeSpiReadWrite(unsig
[Microcontroller]
C51 counter program
//0~200 counter, schematic diagram LEDshow/4.sch #include reg52.h #include math.h void show(unsigned char x,unsigned char n); void delay(unsigned int x); unsigned char tab ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; main() { unsigned char x1,x10,x100;   TMOD=0x06;   TL0=56; //0~200 count   TH0=56;
[Microcontroller]
C51---1 Create a new C51 project + 2.1 Turn on the LED light + 3.1 Press the button to control the LED on and off
1 New construction After selecting the directory path, select add files 2.1 And light up the LED light LED Schematic main function code led1 is P2_0 When the 8-bit control of P2 is set to 1111 1110, the 0th bit is 0, and the LED diode is turned on. #include REGX52.H void main() { P2=0xFE;//1111 1110
[Microcontroller]
C51---1 Create a new C51 project + 2.1 Turn on the LED light + 3.1 Press the button to control the LED on and off
Type conversion of bit and char in C51
Type conversion of bit and char in c51. Data is non-zero, and after bit forced, it is 1. Otherwise, it is 0 The last 8 bits of data are taken after char coercion. (1) What are the benefits of forced conversion? For example: unsigned char x ; sbit SDA = P1^0 ; 1) To use x to record the value of p1.0, you can
[Microcontroller]
Hybrid scheduler C51 source code and related comments
/*===================================================================== 1ms time scale hybrid scheduler (one preemptive task, multiple cooperative tasks) Author: shadow.hu =================================================================================================*/ #include reg52.h #define uchar unsigned char #
[Microcontroller]
C51 Programming 4- Input Level (Independent Buttons)
 I/O port, I stands for Input, O stands for Output. In the previous lecture, the LED is lit by the microcontroller outputting high and low levels to control the LED; this lecture will input levels through buttons, and the microcontroller will detect the input high and low levels and take corresponding actions. Input
[Microcontroller]
C51 Programming 4- Input Level (Independent Buttons)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号