Thank you Mark for you quick answer.
I will enumerate the answers to your comments.
1) You are right, Flex Timer generates the PWM. Any suggestion?
2.1) I configured the "Init_eDMA" componet by Processor Expert to do so. There are only 8 transfers to make the debuggind easier and make sure it works. The real project would have 4000 transfers aprox.
2.2) This transfers are controlled by the DMA hardware of the microcontroller. I configured it by Processor Expert.

2.2) I am not sure to undestand when you ask what is triggering the DMA transfers. The eDMA peripheral request is hardware request: GPIO pin PTD5 makes a request on its rising edge, that is generated by PWM.
3) OK, I see. So you mean that by the time the "Major loop finished" interrupt is executed and PWM is disabled on it, some extra PWM pulses are generated. That makes sense. However, why sometimes I see 8 pulses (target pulses) and 9 and 16 in others?
4) Mechanical bouncing is discarded. I control it by software.
I agree when you say that I need to control the HW directly via DMA and avoid interrupt routines being involved. However I see necesary to use the "Major loop finished" interrupt to be noticed that it is finished. Don´t you think so? And if not, how could I do it?
Any idea to make it work faster?
Thank you very much for your help.