C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
Making PIC18F2620 2nd PWM work correctly... |
Posted: Thu Nov 05, 2009 12:03 pm |
|
|
I have a hair-pulling problem:
I'm using a PIC18F2620 with both PWM's enabled in the standard (not "enhanced" mode and I have the timing/divisors set up so that all 10 bits of resolution are available (that is, PR2 = 0xFF.)
Now, PWM1 works just fine: I can throw any 10 bit value at it and it produces the expected duty cycle.
PWM2, however, has a problem: When the two LSBs of the PWM word are set to "1" (e.g. CCP2CON<5:4> = 0b11) PWM2's output flatlines at a low logic level - that' is, it stops.
Here's what I've tried:
- Using the CCS-supplied PWM functions for both configuring the hardware and setting the duty cycle.
- Writing my very own PWM functions to do the same.
- Looking at the ASM code generated by both sets of code (CCS and mine.) I've also generated code to set up both PWM1 and PWM2 and aside from the expected differences in registers being set up, the code looks the same.
In the meantime, I've simply written an exception to catch the situation where CCP2CON<5:4> = 0b11 and set it to 0b10: Not ideal, but at least it prevents the PWM output from disappearing unexpectedly!
Now, there's likely an errata about this, but I've been unable to locate anything about this, nor have I seen any mention of it elsewhere - even after trying to find it on this forum. Anyone have an idea about this?
At the moment, I have only one batch of older '2620's (probably Rev A-something) so I don't have the latest silicon Rev level - and I have the uneasy feeling that that's my answer:-)
Thanks,
CT |
|