
#include <8051.h>

#define WAIT    1
#define READY   0
#define CLEAR   0
#define SET     1

volatile bit ovf = 0;   /* record the overflow */
volatile bit bit_status = READY;

void isr_byte_recv(void) __interrupt 7;


__sfr __at (0xC9) T2MOD;
__sfr __at (0xC8) T2CON;
__sfr __at (0xCA) RCAP2L;
__sfr __at (0xCB) RCAP2H;

/* T2CON register bits */
__sbit __at (0xC8) CP;
__sbit __at (0xC9) CT2;
__sbit __at (0xCA) TR2;
__sbit __at (0xCB) EXEN2;
__sbit __at (0xCE) EXF2;
__sbit __at (0xCF) TF2;

__sbit __at (0xE8) ET2;

main()
{
        T2CON |= 0x01;
        EXEN2 = 1;
        EA = 1;
        ET2 = 1;
        TR2 = 1;
        while (1) {
                /* my application code here */
        }
}


void isr_byte_recv(void) __interrupt 7
{
        if (TF2 == 1) {         /* check overflow */
                P1_5 = !P1_5;   /* LED2 */
                TF2 = 0;
        }
        if (EXF2 == 1) {
                P3_4 = !P3_4;   /* buzzer */
                EXF2 = 0;
        }
}
