15
To xung vung
V d: To xung vung f=1 KHz ti chn RB0 (Cch 1) #include <16F84.h> #use delay(clock=20000000) Main() { while(1) { output_high(pin_B0); delay_us(500); // delay 250us output_low (pin_B0); delay_us (500 ); } } V d: To xung vung f=1 KHz ti chn RB0 (Cch 2) #include <16F84.h> #use delay(clock=20000000) Main() { int1 x; while(1) { output_bit(pin_B0,!x); delay_us(500); } }
16
04-Jun-11
Delay
dng hm delay, cn c khai bo #use delay (clock=20000000) u file (v d cho fosc=20 MHz) delay_cycles(x) delay x (hng s t 1 255) chu k lnh 1 chu k lnh = 4 chu k my delay_us(x) delay x s x l bin (int16) hoc hng t 0 65535 delay_ms(x) delay x ms x l bin (int16) hoc hng t 0 65535
13