Featured News


Interrupt in microcontroller




#include
void ext0 () interrupt 0
{
    P0=P0>>1;
    if (P0==0)
        P0=0x08;
}

void ext1 () interrupt 2
{
    P0=P0<<1;
    if (P0==0)
        P0=0x10;
}

void main ()
{
    char x;
    P1=0x03;
    P2=0x00;
    P0=0x18;
    EA=1;
    EX0=1;
    EX1=1;
    IT1=1;
    IT0=1;

    while (1)
    {
        x=P1&0x03;

        switch (x)
        {
            case 0:    P2=0x00;
                    break;

            case 1:    P2=0x03;
                    break;

            case 2:    P2=0x06;
                    break;

            case 3:    P2=0x07;
                    break;
        }
    }
}

2 comments:

  1. it's been a long time since I programmed a microcontroller, but I suggest that you add description to your code for easy reading. This might help the newbies understand it more. :)

    ReplyDelete
  2. Thanks Aj Banda, I am on that way...hehehe...I will update this post...soon...aw :)

    ReplyDelete

Thanks for the comment

Scroll to top