Robert Rolf wrote: > Of course. To be clearer, I mess with CCP1 registers for CCP1 > interrupt, (just clearing the int request flag and reading captured > time stamps). > and PWM2 (CCP2) for PWM. There seems to be an interaction between them > even though CCP1 is using TMR1 and PWM2 is using TMR2, and I am ONLY > reading the CCP1 registers, and resetting the interrupt flag. Don't blame the hardware, else you'll never find what you screwed up. Again we're now hearing more bits and pieces of what you're really doing. I still don't have a clear picture. Step back and explain your algorithm, what hardware module does what, when each hardware module is manipulated by the firmware, and how interrupts of each hardware module are used. You may think you've explained this already, but at best it's been in little scattered fragments. Spend 3 paragraphs and do it right so it's all in one place. > (I also compute time difference and do scaling in line for efficiency, > so 300 usec or so of code latency added). See, this is the first time we've heard about "time difference". And what scaling, and in line where? This is getting silly. I'm not spending time on this until you clearly state what you are trying to do. > Short of having someone go over my code independently, I'm > pretty sure it's not a 'bug'. Wrong attitude. > Just an undocumented behaviour of the PIC PWM2 timer chain. LOL. "My perfect program doesn't work, so the PIC must be broken.". Grow up or provide unassailable evidence. > Write to TMR2 > Write to T2CON > ... > " > Since I do BOTH of these in creating a pulse, Whoa, wait a minute. That looks like a obvious bug to me, but then I'm not really sure what you're trying to do. >> So you don't leave the duty cycle at zero apparently. > > Yes, I do. > > clrf CCPR2L ;set next period to zero so only one pulse > out > > is the last think I do in PWM service. But you apparently generate multiple pulses, which I thought you did by mess ing with CCP2. >>> movf Ipw,W ;get pulse width >> >> You forgot to set the bank. That could cause random values right >> there. > > Yes, of course. Then fix that. The rest of the code is irrelevant until you've do that. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist