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

PIC18F2455/2550/4455/4550

15.3Compare Mode

In Compare mode, the 16-bit CCPRx register value is constantly compared against either the TMR1 or TMR3 register pair value. When a match occurs, the CCPx pin can be:

driven high

driven low

toggled (high-to-low or low-to-high)

remain unchanged (that is, reflects the state of the I/O latch)

The action on the pin is based on the value of the mode select bits (CCPxM3:CCPxM0). At the same time, the interrupt flag bit, CCPxIF, is set.

15.3.1CCP PIN CONFIGURATION

The user must configure the CCPx pin as an output by clearing the appropriate TRIS bit.

Note: Clearing the CCP2CON register will force the RB3 or RC1 compare output latch (depending on device configuration) to the default low level. This is not the PORTB or PORTC I/O data latch.

15.3.2TIMER1/TIMER3 MODE SELECTION

Timer1 and/or Timer3 must be running in Timer mode, or Synchronized Counter mode, if the CCP module is using the compare feature. In Asynchronous Counter mode, the compare operation may not work.

15.3.3SOFTWARE INTERRUPT MODE

When the Generate Software Interrupt mode is chosen (CCPxM3:CCPxM0 = 1010), the corresponding CCPx pin is not affected. Only a CCP interrupt is generated, if enabled, and the CCPxIE bit is set.

15.3.4SPECIAL EVENT TRIGGER

Both CCP modules are equipped with a Special Event Trigger. This is an internal hardware signal generated in Compare mode to trigger actions by other modules. The Special Event Trigger is enabled by selecting the Compare Special Event Trigger mode (CCPxM3:CCPxM0 = 1011).

For either CCP module, the Special Event Trigger resets the Timer register pair for whichever timer resource is currently assigned as the module’s time base. This allows the CCPRx registers to serve as a programmable period register for either timer.

The Special Event Trigger for CCP2 can also start an A/D conversion. In order to do this, the A/D converter must already be enabled.

FIGURE 15-2: COMPARE MODE OPERATION BLOCK DIAGRAM

 

 

 

 

Special Event Trigger

 

 

 

CCPR1H

CCPR1L

Set CCP1IF

(Timer1/Timer3 Reset)

 

 

 

 

 

 

 

 

 

 

 

 

 

CCP1 pin

 

Comparator

Compare

Output

S

Q

 

Match

Logic

 

 

 

 

 

R

 

 

 

 

 

 

 

 

 

 

 

4

 

TRIS

 

 

 

 

 

Output Enable

 

 

 

 

CCP1CON<3:0>

 

 

0

TMR1H

TMR1L

0

 

 

 

 

 

 

 

 

1

TMR3H

TMR3L

1

Special Event Trigger

 

 

 

 

(Timer1/Timer3 Reset, A/D Trigger)

 

 

 

 

 

T3CCP1

 

T3CCP2

 

 

 

 

 

 

 

 

 

 

 

 

Set CCP2IF

 

CCP2 pin

 

Comparator

Compare

Output

S

Q

 

Match

Logic

 

 

 

 

 

R

 

 

 

 

 

 

 

 

 

 

 

4

 

TRIS

 

CCPR2H

CCPR2L

 

 

Output Enable

 

 

 

 

 

 

 

 

 

CCP2CON<3:0>

 

 

DS39632D-page 144

Preliminary

2007 Microchip Technology Inc.

PIC18F2455/2550/4455/4550

TABLE 15-3: REGISTERS ASSOCIATED WITH CAPTURE, COMPARE, TIMER1 AND TIMER3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

PIR2

 

OSCFIF

CMIF

USBIF

EEIF

BCLIF

 

HLVDIF

TMR3IF

CCP2IF

54

PIE2

 

OSCFIE

CMIE

USBIE

EEIE

BCLIE

 

HLVDIE

TMR3IE

CCP2IE

54

IPR2

 

OSCFIP

CMIP

USBIP

EEIP

BCLIP

 

HLVDIP

TMR3IP

CCP2IP

54

TRISB

 

TRISB7

TRISB6

TRISB5

TRISB4

TRISB3

 

TRISB2

TRISB1

TRISB0

54

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TRISC

 

TRISC7

TRISC6

 

 

 

TRISC2

TRISC1

TRISC0

54

TMR1L

 

Timer1 Register Low Byte

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TMR1H

 

Timer1 Register High Byte

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

52

 

 

 

 

 

 

 

 

 

 

 

 

T1CON

 

RD16

T1RUN

T1CKPS1

T1CKPS0

T1OSCEN

 

T1SYNC

 

TMR1CS

TMR1ON

52

TMR3H

 

Timer3 Register High Byte

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TMR3L

 

Timer3 Register Low Byte

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

53

 

 

 

 

 

 

 

 

 

 

 

 

T3CON

 

RD16

T3CCP2

T3CKPS1

T3CKPS0

T3CCP1

 

T3SYNC

 

TMR3CS

TMR3ON

53

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

Legend:

— = unimplemented, read as ‘0’. Shaded cells are not used by Capture/Compare, Timer1 or Timer3.

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.

2007 Microchip Technology Inc.

Preliminary

DS39632D-page 145

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