please refer datasheets of both mosfets. I think you need to increase gate voltage for turning, this can be observed through your experiment. as arduino uno 5voutput is 5v pulses from pwm and is fed to mosfet gate. while your stm32 runs at 3.3v so you have gpio pulses at 3.3v.

Also as per theory, if you increase gate voltage, then mosfet internal resistance decreases and current flows more.

You need mosfets with 1.0-1.5V threshold (called "logic level" - you have to double check the Vgs(th) in the datasheet). Mind the threshold is not sharp, it is rather a knee (the threshold voltage does not mean the mosfet is fully "on" running the full Ids current). For example Vgs(th) of the BSS223pw (p-channel low power) is typically 0.9V measured at Ids=1.5uA current (datasheet).
Also mind in order to achieve high switching speed you must drive the mosfet with rather higher peak current because of the gate and miller capacitance (based on mosfet type 40pF - 15nF).
When using pwm via the X channels you do not use analogWrite() - see for example viewtopic.php?f=19&t=3037&start=10#p39347

Since I've been looking at the STM32F4 I've been ignoring this forum. But it happens that a few weeks ago I did exactly what you're looking for.

Originally I had created some Christmas fish bowls that had parallel led strings that were scaling up and down in brightness controlled by a pro-mini, there are six strings each controlled by one of the PWM-capable pins.

Each string's current can rise to ~150mA and so the controlling pro-mini pin went to the gate of a mosfet (2N7000 200mA max or a BS170 500mA max).

Naturally, I wanted to progress to more strings, and I really like the STM32F103 so that was the obvious next step, but with the following considerations:
1. Can the 3.3V signal effectively control the mosfet rather than the pro-mini 5V signal?

2. Looking at the various pinout images available on the internet, there is some inconsistency about those STM32F103 pins that are PWM capable, and how many there actually are. Can we create a definitive list?

3. I prefer to program and debug the STMF103 using serial, but I note that pins A9 & A10 are denoted as PWM pins for timer 1. Can I still use serial to program and debug without losing two PWM pins?

I am happy to say that, after a while investigating and experimenting, the answers are yes, yes, and, yes.

Basically, with each time you effectively set the PWM frequency (via the preset and ARR auto-reload register) for its four channels, and then set the duty cycle for each channel. An example later.

Having a look at the STMCube thingy, it shows that, for timer 1, the pins can be reassigned. This is great news for A9 & A10, all we have to do is figure out how to do it in the Arduino IDE. After looking in timer.h (thanks to the guys here for providing this) and correlating this with the STMCube options, much to my surprise, the first thing I tried worked. Very lucky!

Here's my TEST setup (obviously I have leds in place of the led strings, but each is controlled by the mosfet, which in turn is controlled by the PWM signal from the STM32F103 pin):

You can see that serial UART1 is connected via A9 & A10. The cable colour corresponds to the timer TIM1=blue, TIM2=grey, TIM3=yellow, TIM4=white.

The colour of the led indicates the channel: red=1, yellow=2, green=3, blue=4.

(NOTE: in a "production" environment I would have a 10k ohm pull-down resistor between the mosfet gate and ground, and a ~470 ohm resistor between the gate and the STM32 pin, both are omitted here. The former keeps the leds off for the small time period when the pins are floating between the power turning on and the MCU starting. Another (better) solution would be to have separate power supplies to the STM32 and the leds, the latter only turning on after the STM is initialised. The 470 ohm resistor is not needed if everythng is working happily, but in the event of a problem at the mosfet / led end, it prevents any undesirable voltage / current getting back to the STM.)

The code (NOTE: when I wrote this I was quite literally "messing about with timers" I did not expect anyone else to see it, and it was simply knocked together to check that each of the sixteen channels could be independently controlled):

Hopefully this is helpful and I've remembered everything. If anything seems dodgy please question it, I've probably mis-typed something, I'm watching the Winter Olympics and probably paying less attention than I should to this post!