You are on page 1of 1

y l chng trnh dng ngt Timer0 nh th 1s.

u tin led chn RB0 sng, sau 1s s dch sang tri, ngha l led 1 trn chn RB1 sng , l trn portB v lp li mi mi. #include <16F877A.h> #fuses NOWDT,PUT,XT,NOPROTECT #use delay(clock=4000000) #byte PORTB = 0x06 int16 count; int8 a; //Chuong trinh ngat TMR0 #int_timer0 void interrupt_timer0() { set_timer0(6); ++count; if(count == 2000) // 2000*500us = 500000us = 1s { count=0; rotate_left(&a,1); } } //Chuong trinh chinh void main(void) { set_tris_b(0); enable_interrupts(int_timer0); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2); enable_interrupts(global); set_timer0(6);// T_dinhthi = 2*(256 - 6)*1us = 500us a = 0x01; while(true) { PORTB = a; } }

You might also like