The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL
PROGRAMMING

IN C(cont’)


.....void main() {unsigned char x;P1=0xFF; //make P1 an inputTMOD=0x22;TH1=0xF6; //4800 baud rateSCON=0x50;TH0=0xA4; //5 kHz has T=200usIE=0x92; //enable interruptsTR1=1; //start timer 1TR0=1; //start timer 0while (1) {


x=P1; //read value from pinsSBUF=x; //put value in bufferP2=x; //write value to pins}
}
Free download pdf