Assignment 6 part A

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <reg66x.h>
sbit portpin=P2^0;
void tinit0(void); //timer 0 init function
void delay(unsigned int t); //delay function
void init_intt();
void main()
{init_intt();
tinit0(); //init timer 0
while(1)
{
}}
void tinit0(void) //timer init fuction
{TMOD=0x09; //set timer 0 to mode 1 and gate 0
//TH0=0x6F; //set higher timer reg to 0
//TL0=0xFF; //set lower timer reg to 0
TR0=1;
} //return the pulse width
void init_intt(void)
{
ET0=1;
EA=1;
}
void timer_int (void) interrupt 1
{portpin=!portpin;
TH0=0xB7; //set higher timer reg to 0
TL0=0xFF; //set lower timer reg to 0
}