You've probably read issue 67.
I was experimenting with your pwm sample, modified for the 18f2455. I
have leds connected to both cpp1 and ccp2 (just a 'lucky' co-incidence)
and wanted to see the fading of both leds. So I copied the code for pwm1
and modified it for pwm2. But I made an error with the modification and
saw stange effects with the second led.... This is how I discovered the
bug. I've not checked with Stef's original....
Regards, Rob.
--
Rob Hamerling, Vianen, NL (http://www.robh.nl/)
Rob Hamerling wrote:
> I was experimenting with your pwm sample, modified for the 18f2455. I
> have leds connected to both cpp1 and ccp2 (just a 'lucky' co-incidence)
> and wanted to see the fading of both leds.
Regardless the issue with the pwm libs I have an additional remark.
A comment in your sample says that when turning of pwm the LED lights at
max. In the datasheet of the 18f2455 which I'm using on my test-board I
found (on page 146):
"Clearing the CCP2CON register will force the RB3 or RC1 (...) to the
default low level. This is not the PORTB or PORTC I/O data latch."
With some experimenting with the mentioned PIC I found that after
pwm_off() the LEDs light full up (only) when the pin has been set (= on)
explicitly (before initializing pwm). When I reset the pin (= off) the
LEDs stay off after pwm_off().
Maybe you could repeat this test on your own board (and change the text
if needed).
You've probably read issue 67.
I was experimenting with your pwm sample, modified for the 18f2455. I
have leds connected to both cpp1 and ccp2 (just a 'lucky' co-incidence)
and wanted to see the fading of both leds. So I copied the code for pwm1
and modified it for pwm2. But I made an error with the modification and
saw stange effects with the second led.... This is how I discovered the
bug. I've not checked with Stef's original....
Since the control of PWM (esp. contents of [E]CCPxCON) is more
complicated and the MPLAB .dev files more inconsistent than on first
sight, I have extended the FindCCPCON wiki with the bit names for each
CCPxCON register. The layout is now similar to the FindADCON.
I expect this gives a better insight for improvements of the PWM libs.
Regards, Rob.
PS: The blue question marks in the table are added by Google! I don't
now why and how to avoid it.
That won't work, because the library itself uses CCPON1 rather than
ECCPCON1, however, defining the alias can work
if !defined(ECCPCON1) then
var volatile byte CCP1CON is ECCP1CON
end if
Sebastien Lelong wrote:
> Looking at Rob's wiki page and device files, it appears some PICs
> (18f4480.jal, 18f448.jal, 18f4580.jal, 18f4585.jal, 18f458.jal, 18f4680.jal,
> 18f4682.jal, 18f4685.jal) have both a CCP1CON *and* ECCP1CON register.
I noticed many 'irregularities', mainly in the names of bitfields, but
not this one!
On first sight I thought it would be nice to rename (in the device
files) CCPxCON registers which apparently control an enhanced CCP module
to ECCPxCON. That would make it possible to (partly) split standard and
enhanced PWM libraries. But I don't think this is feasible because of
duplicate names.
However normalizing the names of the bit fields of [E]CCPxCON registers
looks possible without problems.
Maybe we should check how MCC18 solved this problem (if it does).