铮?/div>
-
Resolution = -------------------------------------------------------------------------- bits
log(2)
Note:
If the PWM duty cycle value is longer than
the PWM period the CCP1 pin will not be
cleared.
For an example PWM period and duty cycle calcula-
tion, see the PICmicro鈩?Mid-Range Reference Man-
ual (DS33023).
9.3.3
SET-UP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for PWM operation:
1.
2.
3.
4.
5.
Set the PWM period by writing to the PR2 regis-
ter.
Set the PWM duty cycle by writing to the
CCPR1L register and CCP1CON<5:4> bits.
Make the CCP1 pin an output by clearing the
TRISB<3> bit.
Set the TMR2 prescale value and enable Timer2
by writing to T2CON.
Configure the CCP1 module for PWM operation.
TABLE 9-3:
EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 20 MHz
PWM Frequency
1.22 kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz 208.3 kHz
16
0xFF
10
4
0xFF
10
1
0xFF
10
1
0x3F
8
1
0x1F
7
1
0x17
6.5
Timer Prescaler (1, 4, 16)
PR2 Value
Maximum Resolution (bits)
TABLE 9-4:
Address
REGISTERS ASSOCIATED WITH PWM AND TIMER2
Bit 7
GIE
EEIF
EEIE
Name
Bit 6
PEIE
CMIF
CMIE
Bit 5
T0IE
RCIF
RCIE
Bit 4
INTE
TXIF
TXIE
Bit 3
RBIE
鈥?/div>
鈥?/div>
Bit 2
T0IF
CCP1IF
CCP1IE
Bit 1
INTF
TMR2IF
TMR2IE
Bit 0
RBIF
TMR1IF
TMR1IE
Value on
POR
0000 000x
0000 -000
0000 -000
1111 1111
0000 0000
1111 1111
-000 0000
xxxx xxxx
xxxx xxxx
Value on
all other
RESETS
0000 000u
0000 -000
0000 -000
1111 1111
0000 0000
1111 1111
uuuu uuuu
uuuu uuuu
uuuu uuuu
--00 0000
0Bh, 8Bh,
INTCON
10Bh, 18Bh
0Ch
8Ch
86h, 186h
11h
92h
12h
15h
16h
17h
Legend:
PIR1
PIE1
TRISB
TMR2
PR2
T2CON
CCPR1L
CCPR1H
CCP1CON
PORTB Data Direction Register
Timer2 module鈥檚 register
Timer2 module鈥檚 period register
鈥?/div>
TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0
TMR2ON T2CKPS1 T2CKPS0
Capture/Compare/PWM register1 (LSB)
Capture/Compare/PWM register1 (MSB)
鈥?/div>
鈥?/div>
CCP1X
CCP1Y
CCP1M3
CCP1M2
CCP1M1
CCP1M0
--00 0000
x
= unknown,
u
= unchanged,
-
= unimplemented read as '0'. Shaded cells are not used by PWM and Timer2.
铮?/div>
2002 Microchip Technology Inc.
Preliminary
DS40044A-page 59
prev
next
PIC16F648A相关型号PDF文件下载
-
型号
版本
描述
厂商
下载
-
英文版
8-Pin FLASH-Based 8-Bit CMOS Microcontrollers
-
英文版
8-Pin, 8-Bit CMOS Microcontroller with EEPROM Data Memory
MICROCHIP ...
-
英文版
8-Pin, 8-Bit CMOS Microcontroller with A/D Converter and EEP...
MICROCHIP ...
-
英文版
8-Pin, 8-Bit CMOS Microcontrollers
MICROCHIP ...
-
英文版
EPROM Memory Programming Specification
MICROCHIP ...
-
英文版
8-Pin FLASH-Based 8-Bit CMOS Microcontrollers
MICROCHIP ...
-
英文版
Microcontroller
-
英文版
Microcontroller
-
英文版
Microcontroller
ETC
-
英文版
EPROM-Based 8-Bit CMOS Microcontroller
-
英文版
8-Pin, 8-Bit CMOS Microcontrollers
-
英文版
8-Pin, 8-Bit CMOS Microcontrollers
MICROCHIP ...
-
英文版
ETC
-
英文版
EPROM Memory Programming Specification
-
英文版
EPROM Memory Programming Specification
MICROCHIP ...
-
英文版
28-Pin Programmable Mixed Signal Controller
-
英文版
EPROM Memory Programming Specification
-
英文版
Microcontroller
ETC
-
英文版
Microcontroller
ETC
-
英文版
EPROM/ROM-Based 8-Bit CMOS Microcontroller Series