29.11.2012 Views

LES MICROCONTROLEURS ( PICs de Microchip ) - Technologue pro

LES MICROCONTROLEURS ( PICs de Microchip ) - Technologue pro

LES MICROCONTROLEURS ( PICs de Microchip ) - Technologue pro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

. . . .<br />

1 1 1 1 = post divise par 16.<br />

bit 2 : TMR2ON : mise en service du Timer 2.<br />

1= Timer 2 : On.<br />

0= Timer 2 : Off.<br />

bit 1 et bit0 : T2CKPS : Programmation du pré diviseur.<br />

0 0= pré divise par 1.<br />

0 1= pré divise par 4.<br />

1 X= pré divise par 16.<br />

MODULE CCP : CAPTURE COMPARE et PWM<br />

Il y a <strong>de</strong>ux modules i<strong>de</strong>ntiques CCP1 et CCP2 composés chacun d'un registre 16 bits. Ils<br />

peuvent opérer soit comme un registre 16 bits <strong>de</strong> capture, soit comme un registre 16 bits <strong>de</strong><br />

comparaison, soit enfin comme un registre 8 bits pour générer du PWM.<br />

Le module CCP1 est constitué <strong>de</strong> <strong>de</strong>ux registres <strong>de</strong> 8 bits : CCPR1L en h'15' page 0 et<br />

CCPR1H en h'16' page 0. Ce module est contrôlé par le registre CCP1CON en h'17' page 0.<br />

La sortie en mo<strong>de</strong> COMPARE ou mo<strong>de</strong> PWM et l'entrée en mo<strong>de</strong> CAPTURE se font par la<br />

broche PC2.<br />

Le module CCP2 est constitué <strong>de</strong> <strong>de</strong>ux registres <strong>de</strong> 8 bits : CCPR2L en h'1B' page 0 et<br />

CCPR2H en h'1C' page 0. Ce module est contrôlé par le registre CCP2CON en h'1D' page 0.<br />

La sortie en mo<strong>de</strong> COMPARE ou mo<strong>de</strong> PWM et l'entrée en mo<strong>de</strong> CAPTURE se font par la<br />

broche PC1.<br />

En mo<strong>de</strong> COMPARE ou CAPTURE, les modules utilisent le TIMER 1. En mo<strong>de</strong> PWM, ils<br />

utilisent le TIMER 2.<br />

Les registres <strong>de</strong> contrôles CCP1CON et CCP2CON sont i<strong>de</strong>ntiques. On ne décrira que<br />

CCP1CON.<br />

CCP1CON : ( h'17' : page 0). (et CCP2CON en h'1D' : page 0.)<br />

Au reset : CCP1CON = 00000000<br />

bit 7 et bit 6 : bits non implémentés.<br />

bit 5 et bit 4 : CCP1X et CCP1Y :<br />

Bits non utilisés en mo<strong>de</strong>s Compare et Capture.<br />

Ce sont les 2 bits LSB pour le Duty cycle en mo<strong>de</strong> PWM. Les 8 bits MSB sont dans le<br />

registre CCPR1L en h'15' page 0.<br />

bit 3 à bit 0 : CCP1M3 à CCP1M0 : bits <strong>de</strong> sélection du mo<strong>de</strong>.<br />

0 0 0 0 = Module CCP stoppé.<br />

0 1 0 0 = Mo<strong>de</strong> Capture à chaque front <strong>de</strong>scendant.<br />

0 1 0 1 = Mo<strong>de</strong> Capture à chaque front montant.<br />

0 1 1 0 = Mo<strong>de</strong> Capture tous les 4 fronts montants.<br />

0 1 1 1 = Mo<strong>de</strong> Capture tous les 16 fronts montants.<br />

1 0 0 0 = Mo<strong>de</strong> Compare. Pin <strong>de</strong> sortie mise à "1" et Flag CCP1IF = 1 à l'égalité.<br />

1 0 0 1 = Mo<strong>de</strong> Compare. Pin <strong>de</strong> sortie mise à "0" et Flag CCP1IF = 1 à l'égalité.<br />

Page 22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!