Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:36 25 Feb 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Mapping pin name to PWM channel

Author Message
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 411
Posted: 09:55am 23 Feb 2026
Copy link to clipboard 
Print this post

is there a programatic way to map from pin name to PWM nuber like in

SETPIN GP15, PWMnc  'n=number c=channel


I found no other way so far as to loop thru all number and channel combinations for a given pin name and trapping an error, if any, or using the first non-error path as result, so plain try and error ...

But there is certainly a mor elegant solution I missed ....
                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10982
Posted: 10:02am 23 Feb 2026
Copy link to clipboard 
Print this post

For SETPIN you can just use PWM. You don't need the "nc"
I'll add a new mm.info(pwm pin) that will return the channel for a given pin. Will be in V6.02.01b6
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 411
Posted: 10:05am 23 Feb 2026
Copy link to clipboard 
Print this post

Thanks Peter, wasn't aware of the SETPIN without nc .... the new mm.info will also be helpful in such cases, thank you.
                                                                 
73 de OE1HGA, Gerald
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 411
Posted: 12:07pm 23 Feb 2026
Copy link to clipboard 
Print this post

Peter,

MM.INFO(PWM COUNT) as of the manual does not work ...


> print MM.INFO(PWM COUNT)
Error : Invalid syntax
>

PicoMite MMBasic RP2350B V6.02.01b5
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION PICO OFF
OPTION CPUSPEED (KHz) 200000
                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10982
Posted: 12:16pm 23 Feb 2026
Copy link to clipboard 
Print this post

You need to specify the slice
mm.info(pwm count n)
where n=0-7 for the RP2040 and 0-11 for the RP2350
For mm.info(PWM DUTY n,m) you also need to specify the channel 0 or 1
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 411
Posted: 12:24pm 23 Feb 2026
Copy link to clipboard 
Print this post

Peter,

the manual says for mm.info(pwm count)

"Returns the number of PWM channels supported by the chip"

so I see no use for specifying a "slice", whatever this should be. I tried with several different slice numbers, they all give 65535 as result. Doesn't make sense for me. I would have expected something between 0 and 11, depending on the chip.
                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10982
Posted: 12:27pm 23 Feb 2026
Copy link to clipboard 
Print this post

The manual is wrong - will get it updated. It returns the total count of the pwm slice given the frequency

  Quote  > setpin gp0,pwm
> pwm 0,1000,50
> ? mm.info(pwm count 0)
62999
> pwm 0,1000000,50
> ? mm.info(pwm count 0)
251
>
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026