thắc mắc
Syntax:
set_pwm1_duty (value)
set_pwm2_duty (value)
set_pwm3_duty (value)
set_pwm4_duty (value)
set_pwm5_duty (value)
Parameters:
value may be an 8 or 16 bit constant or variable.
Returns:
undefined
Function:
Writes the 10-bit value to the PWM to set the duty. An 8-bit value may be used if the least significant bits are not required. If value is an 8 bit item it is shifted up with two zero bits in the lsb positions to get 10 bits. The 10 bit value is then used to determine the amount of time the PWM signal is high during each cycle as follows:
Ton = value*(1/clock)*t2div
Where clock is oscillator frequency and t2div is the timer 2 prescaler (set in the call to setup_timer2).
Availability:
This function is only available on devices with CCP/PWM hardware.
Requires:
Nothing
Examples:
// For a 20 mhz clock, 1.2 khz frequency,
// t2DIV set to 16
// the following sets the duty to 50% (or 416 us).
long duty;
duty = 520; // .000416/(16*(1/20000000))
set_pwm1_duty(duty);
Các bạn vui lòng cho mình hỏi : nếu value là 16 bit thì sao,trong khi ở trên nói rằng ghi vào PWM 10 bit .
Với lại "t2div is the timer 2 prescaler (set in the call to setup_timer2)." mình chưa biết dịch ra tiếng Việt thế nào .Rất cảm ơn các bạn chỉ bảo !
|