At89c2051 Projects -

void main() // Configure Timer0 in mode 1 TMOD

void init_uart() SCON = 0x50; TMOD void send_string(char *s) while(*s) SBUF = *s++; while(!TI); TI = 0; at89c2051 projects

Timer/counter modes, frequency measurement techniques. Project 5: Simple Servo Motor Controller Difficulty: Intermediate Components: SG90 or MG995 servo, 5V supply, potentiometer (10k) void main() // Configure Timer0 in mode 1

pos = 0;

Since the AT89C2051 lacks hardware PWM, we generate it using Timer0 interrupt. unsigned int duty = 1500; // 1.5ms center void timer0_isr() interrupt 1 static bit state = 0; if(state == 0) P1_0 = 1; TH0 = 0xFC; // 1ms? Actually calculate for 1.5ms TL0 = 0x18; state = 1; else P1_0 = 0; TH0 = 0xFE; // 20ms - duty TL0 = 0x??; state = 0; TI = 0