Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
Problem With PWM Some Frequencies for Some Pins - FRDM KL25z
Hello guys,
I have a problem I do not know how to solve. I have a PWM 36kHz in PTD0 pin frdm kl25z. This affects the PTE31 PWM pin is also this with a frequency of 36kHz.
Someone help me?
Greetings, Pedro Santos
PwmOut pwm_mot_rig (PTE20); PWM Enable Motor Right 2khz
PwmOut pwm_mot_lef (PTE31); PWM Enable Motor Left 2khz
PwmOut pwm_36khz (PTD0); PWM 36khz IR COMM
SAIDAS DIGITAIS (pwm) PWM Enable Motor Right pwm_mot_rig.period_us(500); pwm_mot_rig.pulsewidth_us(250);
PWM Enable Motor Left pwm_mot_lef.period_us(500); pwm_mot_lef.pulsewidth_us(250);
PWM 36khz IR COMM pwm_36khz.period_us(28); pwm_36khz.write(0.5);
Problem: The PWM of PIN PTE31 gets 36khz. Please Help me.
Assigned to
9 years, 3 months ago.This means that the question has been accepted and is being worked on.
Most mbed platforms support only one PWM frequency at the same time. This is caused by the fact that the PWM hardware on many platforms share the same timer for all PWM outputs. You can only set different duty cycles for the different PWM outputs. The last PWM freq that you set will be used for all PWM outputs. In your case all PWMs will use 36kHz. There are some nucleo boards that do support different PWM freqs on groups of pins. The LPC1549 and some other NXP platforms could also support multiple PWM freqs, but I dont think that is currently implemented in the mbed lib.
posted by Wim Huiskamp 02 Aug 2015Thanks for the answer. I'll have to solve with an external oscillator. I have another question. How do you explain the fact that the PWM work 2kHz all on pins and if I change a value of a duty cycle of a pin board also changes another pin? It seems that the microcontroller confuses pins.
Greetings, Pedro Santos
posted by Pedro Santos 02 Aug 2015