View Full Version : Hỏi Về potscaler TMR2
Xin các bạn cho hỏi công dụng của postscaler trong module TMR2 (PIC 12F683) và cách sử
dụng nó như thế nào
bien_van_khat
03-11-2009, 08:40 AM
Xin các bạn cho hỏi công dụng của postscaler trong module TMR2 (PIC 12F683) và cách sử
dụng nó như thế nào
Postscaler tức là bộ chia sau, tương tự như prescaler là bộ chia trước.
Bộ chia sau dùng để đếm số lần tràn timer (với timer 2 là số lần TMR2 = PR2) trước khi set cờ ngắt.
VD: bạn set postscaler của timer2 là 1:4 tức là cần xảy ra 4 lần liên tiếp (TMR2 = PR2) thì cờ ngắt mới được set.
greenfield
04-11-2009, 10:01 AM
Bạn đọc hết đoạn này sẽ hiểu ngay.
Syntax:
setup_timer_2 (mode, period, postscale)
Parameters:
mode may be one of:
T2_DISABLED, T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16
period is a int 0-255 that determines when the clock value is reset,
postscale is a number 1-16 that determines how many timer overflows before an interrupt: (1 means once, 2 means twice, and so on).
Returns:
undefined
Function:
Initializes timer 2. The mode specifies the clock divisor (from the oscillator clock). The timer value may be read and written to using GET_TIMER2() and SET_TIMER2(). Timer 2 is a 8 bit counter/timer.
Availability:
This function is only available on devices with timer 2 hardware.
Requires:
Constants are defined in the devices .h file.
Examples:
setup_timer_2 ( T2_DIV_BY_4, 0xc0, 2);
// At 20mhz, the timer will increment every 800ns,
// will overflow every 154.4us,
// and will interrupt every 308.8us.
hangocminh1989
04-11-2009, 08:38 PM
tiếng anh kém wá,đọc song không hiểu
hangocminh1989
04-11-2009, 08:38 PM
mong anh em giúo đỡ thêm nhá
Mr.Bi
05-11-2009, 08:11 PM
éc , học VDK mà kém Eng. xem như ít có khả năng code tốt . Hầu hết code source đều từ các trang nc ngoài
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.