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...
Solved! Go to Solution.
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:
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!
-----------------------------------------------------------------------------------------------------------------------
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.
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:
Ant the DevicePtr is in the .h file of the component:
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!
-----------------------------------------------------------------------------------------------------------------------
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:
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!
-----------------------------------------------------------------------------------------------------------------------
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