2 years, 4 months ago.

trouble with interrupt

Hi all, I'm writing a program in k64f using interrupt. I'm using four buttons to activate/deactivate PWM waves on different pins(the first time the buttons are pressed the PWM function starts working and the second time it stops working). when I press one button at a time it works perfectly but, for instance, when one button is pressed already and the PWM pin for that associated button is working and I push one more button, PWM outputs from the pins get disturbed and they affect each other's outcome. I guess that's because they are using the same register in mbed memory for interrupt but how can I fix this problem, that would be great if somebody could help me.

1 Answer

2 years, 4 months ago.

What aspects of the PWM are you setting for each pin?

While the duty cycle for each PWM output is set independently they often share a common clock divider which means all PWMs run at the same frequency. If you set the frequency of one it could impact the frequency of the others.

Generally interrupts should be completely independent of each other. Yes they use a common register but the libraries handle masking them off individually so there is no interaction between them.

Could you post your code? If you do please remember to use

your code there

so that the formatting is correct.

Accepted Answer