Quote:
|
Originally Posted by SuperDanman
...one of timer2's idiosyncrasies is this is the only timer that controls custom PWMs - if you set an output to a user pwm timed by the internal microchip hardware (i.e. no external oscillator or something like that), timer2 is what determines the timing. One period of the PWM signal is the amount of time it takes for timer2 to reach its rollover value and can be changed by either changing the duration of one timer2 clock tick or by changing the PR2, or Timer2 Period Register, value.
|
This is mostly correct. Timer 4 can also be used to generate the PWM frequency. Bits T3CCP1 and T3CCP2 of T3CON control how the timers are assigned (see the illustration on page 150 of the data sheet). I didn't bother to set these bits in my example because I knew that by default timer 2 is used to derive the PWM frequency for CCP2/3. I guess I should add this information to the example code.
Quote:
|
Originally Posted by SuperDanman
The duty cycle of the PWM signal is programmed through the CCPR2L/CCPR3L byte, or the Capture/Compare/PWM Register 1/2 Low Byte. When the timer value is below this register's value, the output pin is high, and when the timer value is above this register's value, the output pin is low. Thus, to create a pwm signal with a 50% duty cycle, you set the CCPRxL value to 1/2 the PR2 value, and to create a signal with a 25% duty cycle, you set the CCPRxL value to 1/4 the PR2 value.
|
Yes, this is true.
Quote:
|
Originally Posted by SuperDanman
Also, what is the relationship between CCPRxL and CCPRxH? I didn't really understand that part of the datasheet.
|
CCPRxH is a double-buffered version of CCPRxL. To prevent PWM output glitching, CCPRxL is transferred to CCPRxH only when it's safe to do so at the low to high transition of the PWM output.
Quote:
|
Originally Posted by SuperDanman
And lastly, there is only CCPR1L, CCPR2L, and CCPR3L, so that means that the pic is capable of generating only three PWM signals (each with the same period, though - timer2's period), right? If this is the case, how do you select which PWM output on the edu uses which custom PWM signal, or does each custom PWM signal control only one PWM output pin?
|
No, the PIC18F8520 has five CCP modules, four of which are available for use (see below).
Quote:
|
Originally Posted by SuperDanman
This kinda implies that CCPR2L is bound to PWM1 and CCPR3L is bound to PWM2. What is CCPR1L used for then, or is the CCPR1L pwm not accessable on the edu?
|
CCP1 doesn't seem to be available for use on the EDU-RC and FRC-RC. On the EDU-RC, CCP2 through CCP5 are available on pins PWM1-4. On the FRC-RC, CCP2 through CCP5 are available on pins PWM13-16. This is documented in IFI's latest version of ifi_aliases.h.
-Kevin