View Single Post
Old 03-07-2010, 08:57 PM   #3
baquyen
Đệ tử 2 túi
 
baquyen's Avatar
 
Tham gia ngày: May 2007
Bài gửi: 31
:
Tớ copy một đoạn trong cuốn sách tiếng Anh nhé (phần PWM), lười dịch quá
setup_timer_2(mode, period, postscale)
initializes timer 2 where mode is
T2_DISABLED
T2_DIV_BY_1
T2_DIV_BY_4
T2_DIV_BY_16

period is an offset value between 0 and 255
before the timer resets postscale is a value between 0 and 16 to determine the times before an interrupt occurs
set_pwm1_duty(value)
this will write the 10 bit value to the PWM module
set_pwm2_duty(value)
If only 8 bits are sent, the 2 lsb’s will be ignored.
Note, value is in the range 0 to period
set_ccp1(CCP_PWM), set_ccp2(CCP_PWM)
this function will initialize the CCP in a PWM mode
Example:
setup_ccp1(CCP_PWM);//sets up for pwm
setup_timer_2(T2_DIV_BY_4, 140, 1);
//140 as offset, timer 4
set_pwm1_duty(70);
//50% duty cycle, i.e. half of 140
__________________
Biển học mênh mông -- Quay đầu là bờ!
My blog
baquyen vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn