hỏi Timer2 của pic16f877a!
setup_timer_2 (mode, period, postscale)
mode :T2_DISABLED, T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16
period : int 0-255
postscale :1-16
bác nào bít cho mình hỏi 3 cái option trên có ý nghĩa như thế nào vậy?
nếu mình muốn ngắt timer2 xảy ra sau 1s thì mình phải set như thế này phải không(thạch anh 20M)?
setup_timer_2(t2_div_by_1,56,16)
#int_timer2
void int_timer2_isr()
{
timer2++;
if(timer2==25000)
{
count++;
timer2=0;
}
}
biến count tăng 1 đơn vị sau 1s.
|