UshoranWhen the duty cycle that I apply on the CCP3 pin its larger than certain value, one output pin configured as digital output takes the high level and other output pin taks low level, while the duty cycle get lower that the value the outputs levels are reversed.
And what is the "certain value"?
Having looked at your code, one thing that stands out like a sore thumb:
You are doing floating point arithmetic in you interrupt service routine. That is going to be chewing up a lot of CPU resources. It's almost certainly at least part of the problem at higher frequencies/duty cycles.
Where ever possible I would suggest removing and using integer arithmetic ONLY.
For example treat all values of tiempo as being multiplied by 200 internally. So compare against 1400 instead of 7.0.
If you absolutely must have floating point arithmetic (hint: there are very few situations where it is absolutely necessary and where integer only/fixed point cannot be made to work the same or better) then confine all floating point calculations to your mainline code so the ISR is not burdened with them.
Edit: Also you should let TMR1 freerun when using CCP. I have no idea why you are resetting it to 0xB1E0. Other than the fact you need to use it for counting 1000 counts and controlling A4/A5. Use a different timer for that, and you CCP code will be substantially easier - no need to check for overflows and wrap arounds for example.
And you didn't give any of your initialization code either, so we have no idea if there is something wrong with the setup of CCP4.
post edited by pcbbc - 2019/07/23 08:08:05