docs

a slatepencil documentail site

View on GitHub

interrupt

interrupt test

hardware

code

/************************
external interrupt test (triggered by LOW)
give P3.2 LOW signal, make LED 4/4 reserve status

connect P3.2 - right lower corner pin
*************************/
#include <reg52.h>

void delay(unsigned int xms)
{
    unsigned int i,j;
    for (i = xms; i > 0; i--)
        for(j = 112; j < 0; j--);
}

void main()
{
    P1 = 0x0f; // 0000 1111 turn on 4 leds & turn off 4 leds
    EX0 = 1; // INT0 interrupt allow
    EA = 1; // global interrupt open
    IT0 = 0; // emit LOW
    while(1);
}

void low() interrupt 0
{
    P1 = ~ P1;
    delay(200);
}
/************************
external interrupt test (down triggered by LOW)

connect P3.3 - P3.6
*************************/
#include <reg52.h>

void main()
{
    P1 = 0x0f; // 0000 1111 turn on 4 leds & turn off 4 leds
    EX0 = 1; // INT0 interrupt allow
    EA = 1; // global interrupt open
    IT0 = 1; // down trigger
    while(1);
}

void jump_low() interrupt 2
{
    P1 = ~ P1;
}