10 years, 5 months ago.

Pwmout on KL25z pins PTD4 and PTC8 are over written

When I use PTD4 and PTC8 as Pwmout on KL25z, the settings of one reflects on the other. On the code below, both PTD4 and PTC8 seems to be set to period of 5 ms and 0.1%. Could someone test the example and check if I am doing something wrong? Sorry if I missed this subject in the questions or in the forum. Thank you very much. Guilherme Franco

  1. include "mbed.h"

PwmOut pwm1(PTD4); PwmOut pwm2(PTC8);

int main() {

pwm1.period_ms(10); pwm2.period_ms(5);

pwm1.write(0.25); pwm2.write(0.1);

while(1) { } }

1 Answer

10 years, 5 months ago.

These two both use the same PWM hardware, so changing one also changes the other. Here is the full list, same PWM name, same PWM hardware:

const PinMap PinMap_PWM[] = {
    {PTA0,  PWM_6,  3}, // PTA0 , TPM0 CH5    
    {PTA1,  PWM_9 , 3}, // PTA1 , TPM2 CH0
    {PTA2,  PWM_10, 3}, // PTA2 , TPM2 CH1
    {PTA3,  PWM_1,  3}, // PTA3 , TPM0 CH0
    {PTA4,  PWM_2 , 3}, // PTA4 , TPM0 CH1
    {PTA5,  PWM_3 , 3}, // PTA5 , TPM0 CH2
    {PTA12, PWM_7 , 3}, // PTA12, TPM1 CH0
    {PTA13, PWM_8 , 3}, // PTA13, TPM1 CH1  
    
    {PTB0,  PWM_7,  3}, // PTB0 , TPM1 CH0
    {PTB1,  PWM_8,  3}, // PTB1 , TPM1 CH1
    {PTB2,  PWM_9,  3}, // PTB2 , TPM2 CH0
    {PTB3,  PWM_10, 3}, // PTB3 , TPM2 CH1
    {PTB18, PWM_9,  3}, // PTB18, TPM2 CH0
    {PTB19, PWM_10, 3}, // PTB18, TPM2 CH1
 
    {PTC1,  PWM_1,  4}, // PTC1 , TPM0 CH0
    {PTC2,  PWM_2,  4}, // PTC2 , TPM0 CH1
    {PTC3,  PWM_3,  4}, // PTC3 , TPM0 CH2
    {PTC4,  PWM_4,  4}, // PTC4 , TPM0 CH3
    {PTC8,  PWM_5 , 3}, // PTC8 , TPM0 CH4
    {PTC9,  PWM_6 , 3}, // PTC9 , TPM0 CH5    
    
    {PTD0,  PWM_1 , 4}, // PTD0 , TPM0 CH0
    {PTD1,  PWM_2 , 4}, // PTD0 , TPM0 CH1
    {PTD2,  PWM_3 , 4}, // PTD2 , TPM0 CH2
    {PTD3,  PWM_4 , 4}, // PTD3 , TPM0 CH3    
    {PTD4,  PWM_5 , 4}, // PTD4 , TPM0 CH4
    {PTD5,  PWM_6 , 4}, // PTD5 , TPM0 CH5
 
    {PTE20, PWM_7,  3}, // PTE20, TPM1 CH0
    {PTE21, PWM_8,  3}, // PTE21, TPM1 CH1
    {PTE22, PWM_9,  3}, // PTE22, TPM2 CH0
    {PTE23, PWM_10, 3}, // PTE23, TPM2 CH1
    {PTE24, PWM_1,  3}, // PTE24, TPM0 CH0
    {PTE25, PWM_2,  3}, // PTE25, TPM0 CH1
    {PTE26, PWM_6,  3}, // PTE26, TPM0 CH5
    {PTE29, PWM_3,  3}, // PTE29, TPM0 CH2
    {PTE30, PWM_4,  3}, // PTE30, TPM0 CH3
    {PTE31, PWM_5,  3}, // PTE31, TPM0 CH4
    {NC   , NC,     0}
};

Accepted Answer

Erik, thank you very much! Regards.

posted by Guilherme Franco 11 Jun 2014