Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Архив4 / Proshin_polnostyu_ves_kursach / pic18f2455_2550_4455_4550.pdf
Скачиваний:
49
Добавлен:
07.08.2013
Размер:
7.07 Mб
Скачать

PIC18F2455/2550/4455/4550

The CCPRxH register and a 2-bit internal latch are used to double-buffer the PWM duty cycle. This double-buffering is essential for glitchless PWM operation.

When the CCPRxH and 2-bit latch match TMR2, concatenated with an internal 2-bit Q clock or 2 bits of the TMR2 prescaler, the CCPx pin is cleared.

The maximum PWM resolution (bits) for a given PWM frequency is given by the equation:

EQUATION 15-3:

FOSC log ---------------

FPWM

PWM Resolution (max) = -----------------------------bits

log (2)

Note: If the PWM duty cycle value is longer than the PWM period, the CCPx pin will not be cleared.

TABLE 15-4: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 40 MHz

PWM Frequency

2.44 kHz

9.77 kHz

39.06 kHz

156.25 kHz

312.50 kHz

416.67 kHz

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Timer Prescaler (1, 4, 16)

16

4

1

1

1

1

 

 

 

 

 

 

 

PR2 Value

FFh

FFh

FFh

3Fh

1Fh

17h

 

 

 

 

 

 

 

Maximum Resolution (bits)

10

10

10

8

7

6.58

 

 

 

 

 

 

 

15.4.3PWM AUTO-SHUTDOWN (CCP1 ONLY)

The PWM auto-shutdown features of the Enhanced CCP module are also available to CCP1 in 28-pin devices. The operation of this feature is discussed in detail in

Section 16.4.7 “Enhanced PWM Auto-Shutdown”.

Auto-shutdown features are not available for CCP2.

15.4.4SETUP FOR PWM OPERATION

The following steps should be taken when configuring the CCP module for PWM operation:

1.Set the PWM period by writing to the PR2 register.

2.Set the PWM duty cycle by writing to the CCPRxL register and CCPxCON<5:4> bits.

3.Make the CCPx pin an output by clearing the appropriate TRIS bit.

4.Set the TMR2 prescale value, then enable Timer2 by writing to T2CON.

5.Configure the CCPx module for PWM operation.

2007 Microchip Technology Inc.

Preliminary

DS39632D-page 147

PIC18F2455/2550/4455/4550

TABLE 15-5:

REGISTERS ASSOCIATED WITH PWM AND TIMER2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reset

Name

 

 

Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

 

Bit 1

 

Bit 0

Values

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

on page

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

INTCON

 

GIE/GIEH

PEIE/GIEL

TMR0IE

INT0IE

RBIE

TMR0IF

INT0IF

RBIF

51

RCON

 

 

IPEN

SBOREN(1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

RI

TO

PD

POR

BOR

PIR1

 

SPPIF(2)

ADIF

RCIF

TXIF

SSPIF

CCP1IF

TMR2IF

TMR1IF

54

PIE1

 

SPPIE(2)

ADIE

RCIE

TXIE

SSPIE

CCP1IE

TMR2IE

TMR1IE

54

IPR1

 

SPPIP(2)

ADIP

RCIP

TXIP

SSPIP

CCP1IP

TMR2IP

TMR1IP

54

TRISB

 

 

TRISB7

TRISB6

TRISB5

TRISB4

TRISB3

TRISB2

TRISB1

TRISB0

54

 

 

 

 

 

 

 

 

 

 

 

 

 

TRISC

 

TRISC7

TRISC6

 

 

TRISC2

TRISC1

TRISC0

54

TMR2

 

Timer2 Register

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PR2

 

Timer2 Period Register

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

 

 

 

 

 

 

 

 

 

T2CON

 

 

T2OUTPS3

T2OUTPS2

T2OUTPS1

T2OUTPS0

TMR2ON

T2CKPS1

T2CKPS0

52

CCPR1L

 

Capture/Compare/PWM Register 1 Low Byte

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CCPR1H

 

Capture/Compare/PWM Register 1 High Byte

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

CCP1CON

 

P1M1(2)

P1M0(2)

DC1B1

DC1B0

CCP1M3

CCP1M2

CCP1M1

CCP1M0

53

CCPR2L

 

Capture/Compare/PWM Register 2 Low Byte

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CCPR2H

 

Capture/Compare/PWM Register 2 High Byte

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

 

CCP2CON

 

 

DC2B1

DC2B0

CCP2M3

CCP2M2

CCP2M1

CCP2M0

53

ECCP1AS

 

ECCPASE

ECCPAS2

ECCPAS1

ECCPAS0

PSSAC1

PSSAC0

PSSBD1(2)

PSSBD0(2)

53

ECCP1DEL

 

PRSEN

PDC6(2)

PDC5(2)

PDC4(2)

PDC3(2)

PDC2(2)

PDC1(2)

PDC0(2)

53

Legend:

— = unimplemented, read as ‘0’. Shaded cells are not used by PWM or Timer2.

 

 

 

 

Note 1:

The SBOREN bit is only available when BOREN<1:0> = 01; otherwise, the bit reads as ‘0’.

 

2:These bits are unimplemented on 28-pin devices; always maintain these bits clear.

DS39632D-page 148

Preliminary

2007 Microchip Technology Inc.

Соседние файлы в папке Proshin_polnostyu_ves_kursach