Portenta PWM pinout

I try to use PWM timer with a portenta.
I follow the example provided in the example folder for the portenta:

import time
from pyb import Pin, Timer
tim = Timer(4, freq=1000) # Frequency in Hz
ch1 = tim.channel(1, Timer.PWM, pin=Pin("P7"), pulse_width_percent=50)

But i have the message “Pin(P7) doesn’t exist”
I have try differnet namming for the pin.
When i put Pin(“PC7”) i then have the following error:
"Pin(C7) doesn’t have an af for timer(4)
I have try randomly and if i put Pin(PB7) it doesn’t spit any error message
But according to the arduino pinout there is no PB7
What’s going on ?
I want to try the one name “PC7” on the portenta pinout diagram.
Where can i find the proper pin name to use pwm?

USE the orange column of the Pinout description: https://store.arduino.cc/portenta-h7
All the Pins start with P like ‘PC6’, ‘PC7’, ‘PG7’

Hi, we need to improve documentation for the Portenta. I will be doing this soon:

The example is likely wrong, I copied it from OpenMV examples. Will need to check the pinout to find which pins map to which timer/channels and enable them for Python.

Thanks for your answer.
I did exactly that. PC7 is labeled as PWM but i have error “Pin(C7) doesn’t have an af for timer(4)”

Hi, use this updated script, this will enabled all the available PWMs… Please see the PWM to PIN/TIM/CH mapping.
Note there’s only 1 free PWM (PWM7) if you connect the vision shield.

thanks for your help.
Only PWM7 is available with the vision shield?
I did not notice that. My plan was to program on PWM3,
I guess i have to change it :slight_smile:

I’ll try your code today.
Thanks again

Other pins may be free it depends on the exact shield you have, and what it has on board, but to be on the safe side you should only use PWM7 while using the vision shield.

I have just tried it out and it work with the PWM3 if i don’t use the camera at the same time. Which is my case in my code. i just use the camera to capture image for qrcode reading.