Author Topic: Change Timer/Channel associated pin for PWM  (Read 2788 times)

Offline Raffaele

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Change Timer/Channel associated pin for PWM
« on: November 11, 2020, 11:11:53 PM »
Hi,

I'm trying to generate two different PWMs on a KL03. One uses pwm_reference = (_TIMER_1 | 0); and the associated pin is PTA0. This works.
For the other one I want to use PTA12. However, the KL family manual reports  TPM1_CH0 for both PTA0 and PTA12.

To change this, in the file kinetis_PWM.h I changed _CONFIG_PERIPHERAL(B, 11,(PORT_MUX_ALT2 | PORT_SRE_FAST | PORT_DSE_HIGH)); to _CONFIG_PERIPHERAL(A, 12,(PORT_MUX_ALT2 | PORT_SRE_FAST | PORT_DSE_HIGH));
so that the pwm_reference for PTA12  is now  TPM0_CH0 instead of  TPM1_CH0.

I set up 2 different PWMs on PTA0 and PTA12, but both pins generate the same PWM of  TPM1_CH0 A0. In other words, I am not able to modify the PWM on PTA12. Is there anything else I need to change in the code?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Change Timer/Channel associated pin for PWM
« Reply #1 on: November 12, 2020, 12:53:06 PM »
Hi

The pin multiplexing capabilities are governed by the HW and can't be change in software.
That means that if you configure PTA12 to its alternative function 2 it will internally connect it to TMP1_CH0 - it is impossible to connect it to TPM0_CH0.
Therefore the only solution is to use a different pin that can be connected to TPM0.

Regards

Mark