Showing Visitor Messages 1 to 1 of 1
-
Em thân ái chào tất cả anh chị em trong diễn đàn. cho em xin phép hỏi phần timer0 của Pic 16f877a. em muốn tạo delay_1s bằng timer0. em tính toán thế này không biết đúng không. nhưng chắc chắn mô phỏng là sai. thực sự em nghĩ mãi nhưng vẫn chưa hiểu. rất mong diễn đàn giúp đỡ em
#include <16F877A.h>
#fuses nowdt,put,hs,noprotect
#use delay(clock=20000000)
#byte portb = 0x06
int16 count;
int8 a;
#int_timer0
void interrupt_timer0()
{
clear_interrupt(int_timer0);
disable_interrupts(global);
++count;
if(count==20000)
{
count=0;
rotate_left(&a,1);
}
set_timer0(5);
enable_interrupts(global);
}
void main(void)
{
set_tris_b(0);
enable_interrupts(int_timer0);
setup_timer_0(RTCC_INTERNAL);
enable_interrupts(global);
set_timer0(5);//T=50us
a=0x01;
while(true)
{
portb = a;
}
}