PWM Component Sharing - ConnectPin()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM Component Sharing - ConnectPin()

Jump to solution
676 Views
abhiembedded
Contributor I

Hi,

I am trying to setup a program that outputs a PWM signal but also has the ability to hold the signal on the same pin high or low 'manually'. The PWM is working fine, and I can disable it to simply hold the output low. However, the KL25 does not let me set the output as high. Therefore, I wanted to use a BitIO component to set the pin to high. I can add this component and it appears to work, using pin sharing.

However, the PWM component doesn't have a ConnectPin() method, so can't connect the pin back to the PWM output - it just stays stuck to the BitIO. I am using a PWM high level component. I see that the LDD has a ConnectPin method, but this is not available in the high level component.

I can use a PWM LDD directly, instead of the high level component, but I do not understand the arguments that need to be passed to the ConnectPin() function for the PWM LDD, what should the pin mask be?

Could someone help with how to achieve this...

0 Kudos
1 Solution
477 Views
adriancano
NXP Employee
NXP Employee

Hi,

The High Level components only support the common features of the LDD components, this means that the possible configurations are limited to the basic functionality of the peripheral, that is the reason why the ConnectPin() method is not available for the High Level Component.

Regarding the use of the method it has two parameters:

  • DeviceDataPtr: Pointer to LDD_TDeviceData - Device data structure pointer returned by Init method. Is the same pointer that is passed to all the other methods of the LDD component. The High Level Component do not use this parameter because is already generated by processor expert.
  • PinMask:LDD_TPinMask - Mask for the requested pins. The peripheral pins are reconnected according to this mask. This one is also generated by processor expert, you can check the value in the .h file for the specific PWM component. Here is an image for your reference:

          connect pin.jpg

You can call the method like this:

PWM1_ConnectPin(PWMTimerRG_DeviceData, (LDD_TPinMask)PWM1_OUT_PIN);


Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
4 Replies
477 Views
abhiembedded
Contributor I

Thanks - both approaches worked for me, problem solved!

In the Processor Expert approach - I had to set the "Auto Initialisation" option to 'yes' otherwise I had no way of getting the DeviceDataPtr.

0 Kudos
477 Views
adriancano
NXP Employee
NXP Employee

Hi,

If you configure the autoinitialization YES the Init method is called in the PE_low_level_init function, you can see an example here:

init.jpg

Ant the DevicePtr is in the .h file of the component:

pwm.jpg

If you configure the autoinitialization NO you need to call the Init method in your code where you need it. The init method return a pointer to the device structure that is the one you will use and you can name it as you want, here an example in main.c file

LDD_TDeviceData *MyPWM1Ptr;

int main(void)

{

    PE_low_level_init();

    MyPWM1Ptr = PWM1_Init(NULL);

    //connect pin function example

    PWM1_ConnectPin(MyPWM1Ptr, (LDD_TPinMask)PWM1_OUT_PIN);

    for(;;){

          //user code  

    }

Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
478 Views
adriancano
NXP Employee
NXP Employee

Hi,

The High Level components only support the common features of the LDD components, this means that the possible configurations are limited to the basic functionality of the peripheral, that is the reason why the ConnectPin() method is not available for the High Level Component.

Regarding the use of the method it has two parameters:

  • DeviceDataPtr: Pointer to LDD_TDeviceData - Device data structure pointer returned by Init method. Is the same pointer that is passed to all the other methods of the LDD component. The High Level Component do not use this parameter because is already generated by processor expert.
  • PinMask:LDD_TPinMask - Mask for the requested pins. The peripheral pins are reconnected according to this mask. This one is also generated by processor expert, you can check the value in the .h file for the specific PWM component. Here is an image for your reference:

          connect pin.jpg

You can call the method like this:

PWM1_ConnectPin(PWMTimerRG_DeviceData, (LDD_TPinMask)PWM1_OUT_PIN);


Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
477 Views
mjbcswitzerland
Specialist V

Hi Abhi

I would write directly to the PORTn_PCRx control register for the pin(s) in question.

If you configure the GPIO mode as output with either '0' or '1' you can then swap between PWM output and a '1' or '0' with a single register write.

Furthermore, if you have multiple such outputs it is even possible to switch up to 16 between the functions at exactly the same point in time by a single register write using

PORTn_GPCLR or

PORTn_GPCHR

Regards

Mark

Kinetis: µTasker Kinetis support

KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support

For the complete "out-of-the-box" Kinetis experience and faster time to market