8 years, 9 months ago.

implement using nucleo f302r8

i am trying to implement the fast pwm on f302r8,

i get this error

Error: Undefined symbol getChannel(TIM_TypeDef*, PinName) (referred from FastPWM_STM_TIM.cpp.NUCLEO_F302R8.o).

is it because the board is not supported?

I use this code: /media/uploads/rouaze/main.cpp

Question relating to:

Erik - / FastPWM Featured
Library that allows for higher resolution and speed than standard mbed PWM library using same syntax (drop-in replacement). pwm, resolution, Speed

1 Answer

8 years, 9 months ago.

Correct. Due to how the PWM library of the STM boards is implemented for mbed, I cannot automatically use the data from it. However in general it is quite easy to add your board, you can check the STM32 pinout. The pins for your board you can get from either the reference manual or the mbed source code.

Edit: I just checked that, and at least for your board it seems they finally properly made the pwm code, and now i can get it in the FastPWM lib from the source code. I need to see if this is true for all STM boards, but if yes I can make it function for all STM boards. That said, don't know when i get around to implementing that (within a week or so probably, but no guarantees).

Edit2: I modified the library to use for roughly half the STM32 the mbed library code to get the channel number, for the others this is not possible due to how their code is setup. That means now all F3s are supported. For the F401 this new method seems to work, but I could only test it once before it broke down again, pretty sure my board is dead. My other board is an F0, but that one still needs to use the old method, so I cannot really verify if it works. So please test it and report back if it works for you :). (You need latest FastPWM version, right mouse button, update, and not a very old mbed lib version).

Accepted Answer

Thanks Erik, you are doing such amazing work on this site I use a lot of your libraries, I will let you know tomorrow if I can get it working on that board. Thanks for all your amazing work! just as a matter of interest what part of the file did you change to add the pinout? i wouldn't mind having a look to see if i can learn something. again, i cant thank you enough.

edit; it seems we have success compiling ill have a look on the oscilloscope tomorrow but it is looking good!

posted by Pierre rouaze 29 Feb 2016

Erik, did you create an issue for this - that their PWM the way it was implemented

posted by Martin Kojtal 01 Mar 2016

@Pierre, I didn't, I removed part of it :). In some of the STM32 series, including the F3 apparantly, they now save in an internal PwmOut variable which channel a certain pin is (like every other target also does). Since I inherit PwmOut I can read this also out, and simply use this now to figure out which channel I should use.

Other (older) STM32 code still uses the method where everytime the pwm write function is called, it again goes through a list to figure out which channel it should use. So for those targets I still need to manually implement it, since they do not save it in an internal variable I can read from.

@Martin, the problem is not that their PwmOut does not work (although it is kinda glitchy, but thats true for most targets these days sadly), the problem is that it is slow and ugly code. But it does work for them.

posted by Erik - 01 Mar 2016