7 years, 2 months ago.

Alternative pwm pins

Hi,

For my project, I use a NUCLEO F446RE. I want to use PWM_11 to PWM_14 because the other timers are already occupied for encoder input capturing. In the mbed-src file (https://os.mbed.com/users/mbed_official/code/mbed-src/file/a11c0372f0ba/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446RE/PeripheralPins.c), the pinpap for these pwm channels are commented because it are alternative possibilities. It says: "If you change them, you will have also to modify the corresponding xxx_api.c file for pwmout, analogin, analogout, ...". But where can I find this file and how do I change it?

Thanks Ward

Hi Ward In order to "customize" mbed you will need to do the following assuming you are doing cloud based builds.

  • 1) Delete the "mbed" library folder in your current project
  • 2) Go to Github and fork the mbed-os
  • 3) "Import" that URL into your project
  • 3.1) Build your project as a test and make sure it builds just like it did when you had the mbed library folder
  • 4) Tunnel down into the folders now that they are imported and find the targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE folder. In there you will find the PeripheralPins.c file.
  • 5) Make the mod as suggested by bco stm and then recompile.

Hope that helps Bill

posted by Bill Bellis 05 Oct 2017

It is not possible to open the file in the online compiler, but I exported the program to an offline compiler. This way it works. Thanks a lot!

posted by Ward Vandenbroucke 05 Oct 2017

It works just fine. You must not have followed the instructions exactly. When you import the URL of your forked repository (not the mbed one, but YOUR fork) you can edit away. And I only use the online build - never have done CLI.

posted by Bill Bellis 05 Oct 2017

Nice tip about the forking Bill!

posted by Jan Jongboom 06 Oct 2017

2 Answers

7 years, 2 months ago.

The sources for mbed are here: https://github.com/ARMmbed/mbed-os There are lots of topics on how to do this. Take a look through the sources listed and see if you have further questions. Most of the templates for expanding features are in place.

Accepted Answer

Hi Bill, Thanks for the answer. If I import this library to the online mbed compiler, I could not open the PeripheralPins.c file. If I only copy the PeripheralPins.c file, it gives as error: "Symbol ... is multiply defined by PeripheralPins.o". What is the right way to do this? I am sorry if this is a stupid question.

posted by Ward Vandenbroucke 04 Oct 2017

I'm not sure if you can change the mbed-os sources in online compiler. Give Mbed CLI a try, it will work.

posted by Jan Jongboom 05 Oct 2017

You can edit a forked copy of course.

posted by Bill Bellis 05 Oct 2017
7 years, 2 months ago.

For example if you want to use PWM_11 (instead of PWM_4) on PB_9, you have to do this in the PeripheralPins.c file:

//  {PB_9,  PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)},  // TIM4_CH4
    {PB_9,  PWM_11,STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11,1, 0)},  // TIM11_CH1

It should be enough.

The Note in the header is obsolete and will be changed.