Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:45 19 Nov 2025 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 : PicoMite: what's wrong with SETPIN 17,PWM0A?

Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3478
Posted: 05:18pm 16 Jul 2021
Copy link to clipboard 
Print this post

PicoMite MMBasic Version 5.07.00a48
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather
> SETPIN 1,PWM0A
> SETPIN 17,PWM0B
Error : Invalid configuration
> new
> setpin 17,PWM0A
Error : Invalid configuration
>
PicoMite MMBasic Version 5.07.00a48
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather
> setpin 17,PWM0A
Error : Invalid configuration
>
> option list
OPTION SYSTEM I2C GP10,GP11
OPTION LCDPANEL SSD1306I2C, LANDSCAPE
OPTION RTC AUTO ENABLED
OPTION GUI CONTROLS 59
OPTION MEMORY 60160, 100608
>

~
Edited 2021-07-17 03:21 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8297
Posted: 05:48pm 16 Jul 2021
Copy link to clipboard 
Print this post

Don't you have to configure them in matching slices, as per page 101 of the Micropython book? So PWM_A[0] on pin 1 is paired with PWM_B[0] on pin 2 or PWM_B[0] on pin 22. Not sure...
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10610
Posted: 05:54pm 16 Jul 2021
Copy link to clipboard 
Print this post

  Quote  PWM_B[0] on pin 22


pin 22 == GP17
Edited 2021-07-17 03:54 by matherp
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3478
Posted: 07:20pm 16 Jul 2021
Copy link to clipboard 
Print this post

I wasn't looking for GP17, but pin 17, GP13.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10610
Posted: 07:52pm 16 Jul 2021
Copy link to clipboard 
Print this post

GP13 is PWM06B

   { 1,  0, "GP0",  DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI0RX | I2C0SDA | PWM0A,99,0},   // pin 1
{ 2,  1, "GP1",  DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM0B ,99,128},     // pin 2
{ 3, 99, "GND",  UNUSED  ,99,99},                                                         // pin 3
{ 4,  2, "GP2",  DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM1A ,99,1},      // pin 4
{ 5,  3, "GP3",  DIGITAL_IN | DIGITAL_OUT | SPI0TX | I2C1SCL | PWM1B ,99,129},     // pin 5
{ 6,  4, "GP4",  DIGITAL_IN | DIGITAL_OUT | UART1TX | SPI0RX | I2C0SDA | PWM2A ,99,2},   // pin 6
{ 7,  5, "GP5",  DIGITAL_IN | DIGITAL_OUT | UART1RX | I2C0SCL | PWM2B ,99,130},     // pin 7
{ 8, 99, "GND",  UNUSED  ,99, 99},                                                         // pin 8
{ 9,  6, "GP6",  DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM3A ,99, 3},   // pin 9
{ 10,  7, "GP7",  DIGITAL_IN | DIGITAL_OUT |  SPI0TX | I2C1SCL | PWM3B ,99, 131},    // pin 10
   { 11,  8, "GP8",  DIGITAL_IN | DIGITAL_OUT | UART1TX | SPI1RX | I2C0SDA | PWM4A ,99, 4}, // pin 11
{ 12,  9, "GP9",  DIGITAL_IN | DIGITAL_OUT | UART1RX | I2C0SCL | PWM4B ,99, 132},     // pin 12
{ 13, 99, "GND",  UNUSED  ,99, 99},                                                        // pin 13
{ 14, 10, "GP10",  DIGITAL_IN | DIGITAL_OUT | SPI1SCK | I2C1SDA | PWM5A ,99, 5},   // pin 14
{ 15, 11, "GP11",  DIGITAL_IN | DIGITAL_OUT | SPI1TX | I2C1SCL | PWM5B ,99, 133},       // pin 15
{ 16, 12, "GP12",  DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI1RX | I2C0SDA | PWM6A ,99, 6},  // pin 16
{ 17, 13, "GP13",  DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM6B ,99, 134},     // pin 17
{ 18, 99, "GND", UNUSED  ,99, 99},                                                         // pin 18
{ 19, 14, "GP14",  DIGITAL_IN | DIGITAL_OUT | SPI1SCK | I2C1SDA | PWM7A ,99, 7},     // pin 19
{ 20, 15, "GP15",  DIGITAL_IN | DIGITAL_OUT | SPI1TX | I2C1SCL | PWM7B ,99, 135},   // pin 20

{ 21, 16, "GP16",  DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI0RX | I2C0SDA | PWM0A ,99, 0},  // pin 21
{ 22, 17, "GP17",  DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM0B ,99, 128},     // pin 22
{ 23, 99, "GND",  UNUSED  ,99, 99},                                                        // pin 23
   { 24, 18, "GP18",  DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM1A ,99, 1}, // pin 24
   { 25, 19, "GP19",  DIGITAL_IN | DIGITAL_OUT | SPI0TX | I2C1SCL | PWM1B ,99, 129},      // pin 25
   { 26, 20, "GP20",  DIGITAL_IN | DIGITAL_OUT | I2C0SDA | PWM2A ,99, 2},            // pin 26
   { 27, 21, "GP21",  DIGITAL_IN | DIGITAL_OUT | I2C0SCL | PWM2B ,99, 130},     // pin 27
{ 28, 99, "GND",  UNUSED  ,99, 99},                                                        // pin 28
{ 29, 22, "GP22",  DIGITAL_IN | DIGITAL_OUT | PWM3A ,99, 3},             // pin 29
{ 30, 99, "RUN",  UNUSED  ,99, 99},                                                        // pin 30
   { 31, 26, "GP26",  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | I2C1SDA | PWM5A , 0 , 5},        // pin 31
   { 32, 27, "GP27",  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | I2C1SCL | PWM5B , 1 , 133},        // pin 32
{ 33, 99, "AGND", UNUSED  ,99, 99},                                                         // pin 33
{ 34, 28, "GP28",  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | PWM6A , 2 , 6},                  // pin 34
   { 35, 99, "VREF", UNUSED  ,99, 99},                                                         // pin 35
{ 36, 99, "3V3", UNUSED  ,99, 99},                                                         // pin 36
{ 37, 99, "3V3E", UNUSED  ,99, 99},                                                         // pin 37
{ 38, 99, "GND", UNUSED  ,99, 99},                                                         // pin 38
{ 39, 99, "VSYS", UNUSED  ,99, 99},                                                         // pin 39
{ 40, 99, "VBUS", UNUSED  ,99, 99},                                                         // pin 40
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3478
Posted: 08:32pm 16 Jul 2021
Copy link to clipboard 
Print this post

Ah, thanks. I missed that configuration. Does that imply that pin 16 is not available as DOUT or DIN if pin 17 is configured as PWM?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3478
Posted: 11:26pm 16 Jul 2021
Copy link to clipboard 
Print this post

  lizby said  Does that imply that pin 16 is not available as DOUT or DIN if pin 17 is configured as PWM?

So the answer is "yes".

PicoMite MMBasic Version 5.07.00a48
Copyright 2011-2021 Geoff Graham
Copyright 2016-2021 Peter Mather

> setpin 17,PWM6b
> PWM 6,1000,0,50
Error : Pin not set for PWM
> setpin 16,PWM6a
> PWM 6,1000,0,50
>

(And the PWMed LED on pin 17 comes on.)

My immediate problem is that I've allocated pin 16 for SPI2 MISO. Some head-scratching is in order.

By the way, does this accurately display what's available in the way of PWM?



~
Edited 2021-07-17 10:15 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8297
Posted: 06:16am 17 Jul 2021
Copy link to clipboard 
Print this post

That agrees with the Micropython book, so I assume it does. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10610
Posted: 06:48am 17 Jul 2021
Copy link to clipboard 
Print this post

  Quote  Does that imply that pin 16 is not available as DOUT or DIN if pin 17 is configured as PWM?


  Quote  There are 8 separate PWM frequencies available (0 - 7) and up to 16 outputs with individually controlled duty cycle. You can output on either PWMnA or PWMnB or both for each channel - no restriction


PWM channel, frequency, [duty1] [,duty2]
PWM channel, OFF


Try

setpin 17,PWM6b
PWM 6,1000,,50

Edited 2021-07-17 18:20 by matherp
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2466
Posted: 10:53am 17 Jul 2021
Copy link to clipboard 
Print this post

peter,
   would there be any material difference between the below two code snipets?

setpin 16,PWM6a
setpin 17,PWM6b

and

setpin 16,PWM
setpin 17,PWM


the PWM channel number (0-7) and letter (a or b) associated with any given pin is fixed (eg, pin 17, when configured for PWM, can only ever be channel 6b), so there seems no real point in explicitly stating the channel number/letter in the setpin command.


given the above is accepted, it further (but separately) seems that with the PWM command:

PWM channel, frequency, [duty1] [,duty2]

it may be more intuitive (albeit not syntactically compatible with other mmbasic versions) to use the pin number instead of the channel number/name. the firmware can always, unambiguously, resolve the pin number back to the channel number and letter, and an error can be generated if an incompatible pin number is used (eg, 21/22 instead of 1/2 if pins 1 and 2 have previously been configured for PWM with setpin).


cheers,
rob   :-)
Edited 2021-07-17 21:11 by robert.rozee
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3478
Posted: 11:58am 17 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  Try

setpin 17,PWM6b
PWM 6,1000,,50

That does the trick. Thank you. No need to rethink the configuration and scramble traces.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
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 2025