Bonjour
En voulant programmer deux signaux PWM avec 2 fréquences différentes sur un PIC16F18325, je me suis rendu compte que dans le datasheet de ce µC il y a deux explications différentes pour programmer un signal PWM. Page 193 et Page 305... C'est peut être mon anglais mais je ne vois pas vraiment quelle différence il y a entre les deux. Pourtant les procédures de SETUP sont différentes :
Page 195 :
Page 306 :Code:19.1.7 SETUP FOR PWM OPERATION The following steps should be taken when configuring the module for using the PWMx outputs: 1. Disable the PWMx pin output driver(s) by setting the associated TRIS bit(s). 2. Configure the PWM output polarity by configuring the PWMxPOL bit of the PWMxCON register. 3. Load the PR2 register with the PWM period value, as determined by Equation 19-1. 4. Load the PWMxDCH register and bits <7:6> of the PWMxDCL register with the PWM duty cycle value, as determined by Equation 19-2. 5. Configure and start Timer2: • Clear the TMR2IF interrupt flag bit of the PIR1 register. • Select the Timer2 prescale value by configuring the T2CKPS bit of the T2CON register. • Enable Timer2 by setting the TMR2ON bit of the T2CON register. 6. Wait until the TMR2IF is set. 7. When the TMR2IF flag bit is set: • Clear the associated TRIS bit(s) to enable the output driver. • Route the signal to the desired pin by configuring the RxyPPS register. • Enable the PWMx module by setting the PWMxEN bit of the PWMxCON register.
Une idée ?Code:29.4.2 SETUP FOR PWM OPERATION The following steps should be taken when configuring the CCP module for standard PWM operation: 1. Use the desired output pin RxyPPS control to select CCPx as the source and disable the CCPx pin output driver by setting the associated TRIS bit. 2. Load the PR2 register with the PWM period value. 3. Configure the CCP module for the PWM mode by loading the CCPxCON register with the appropriate values. 4. Load the CCPRxL register and the CCPRxH register bits, with the PWM duty cycle value and configure the CCPxFMT bit of the CCPxCON register to set the proper register alignment. 5. Configure and start Timer2, 4 or 6. • Clear the TMR2/4/6IF interrupt flag bits of the PIR4 register. See Note below. • Configure the T2/4/6CKPS bits of the T2/4/6CON register with the Timer prescale value. • Enable the Timer by setting the TMR2/4/6ON bit of the T2/4/6CON register. 6. Enable PWM output pin: • Wait until the Timer overflows and the TMR2/4/6IF bits of the PIR4 register is set. See Note below. • Enable the CCPx pin output driver by clearing the associated TRIS bit.
Merci
-----