Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:18 27 Jul 2024 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 : micromite pwm commands

Author Message
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 05:23pm 09 Jun 2024
Copy link to clipboard 
Print this post

I want to use gp16 (pin21) as pwm. With SETPIN gp16, PWM I can set PWM, 0, 1000, 50 to get 1KHz 50% duty cycle OK. But when I try to stop it with PWM 0, OFF it tells me I ERROR pin not set for the PWM, 0, 1000, 50 instruction. However I have already seen the 1KHz signal on my scope before I introduced the PWM 0, OFF instruction.
So what am I doing that is not right?
Many thanks for any help.
Roy
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1911
Posted: 09:56pm 09 Jun 2024
Copy link to clipboard 
Print this post

I don't see that problem on RC5 but do get other odd things with PWM error handling.
> option list
PicoMite MMBasic Version 5.09.00RC5
OPTION FLASH SIZE 16777216
OPTION CPUSPEED  420000 'KHz

> SETPIN gp16, PWM
> PWM 0, 1000, 50
> PWM 0, OFF
> SETPIN gp0, PWM
> PWM 0, 1000, 50
> SETPIN gp16, PWM
Error: Invalid address - resetting


Invalid clock speed - reset to default
> option list
PicoMite MMBasic Version 5.09.00RC5
OPTION FLASH SIZE 16777216

> OPTION CPUSPEED  420000
> SETPIN gp16, PWM
> SETPIN gp0, PWM
Error : Already Set to pin -9067575637245427710
> PWM 0, 1000, 50
> PWM 0, OFF
>
 
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 03:18pm 11 Jun 2024
Copy link to clipboard 
Print this post

Hi Guru, Thanks for your reply. It seems to confirm that it does not behave as per picomite manual. I will keep trying various things and if I cant get it to work then will have to move on and try some sort of work-around, like adding a hardware oscillator.
I already do have PWM on gp28 and it works but its driving a servo and I never try to stop it with a PWM 6, OFF
Roy
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8683
Posted: 03:49pm 11 Jun 2024
Copy link to clipboard 
Print this post

The above bug is fixed in the latest download
 
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 03:42pm 12 Jun 2024
Copy link to clipboard 
Print this post

Hi matherp
Many thanks for this info. I will update my system in the next day or so and try again.
Roy
 
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 04:45pm 14 Jun 2024
Copy link to clipboard 
Print this post

Hi matherp
I have downloaded and installed the latest version which seems to be V5.08.00.uf2
downloaded from the ref as per micromite user manual http://geoffg.net/picomite.html

But still have problems.
I have

setpin gp16, pwm
pwm 0, 1000, 50

this runs until the following line is executed

pwm 0, off

and then it gives an error message

pwm 0, 1000, 50
error : pin not set for pwm

Note gp16 is not used for anything else.

Have I downloaded the latest version?

Many thanks
Roy
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3811
Posted: 05:58pm 14 Jun 2024
Copy link to clipboard 
Print this post

When you stop the pwm, the pin is also disconnected, very handy if you want to re-purpose the pin.

So after pwm 0,off
You must again
Setpin gp16,pwm
PWM 0,1000,50

Alternatively you can keep the pwm running at 0% duty cycle
PWM 0,1000,0

Then the pwm keeps connected to gp16


Volhout
Edited 2024-06-15 04:02 by Volhout
PicomiteVGA PETSCII ROBOTS
 
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 06:31pm 14 Jun 2024
Copy link to clipboard 
Print this post

Hi Volhout certainly setting it to a zero duty cycle works.
Many thanks
Roy
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8683
Posted: 06:45pm 14 Jun 2024
Copy link to clipboard 
Print this post

  Quote  When you stop the pwm, the pin is also disconnected


This is the same for all I/O modes : I2C, SPI, PWM, UART
When you close the usage the pins are released back to unallocated

This is how it is intended so as Volhout says if you set the PWM to OFF you will need to SETPIN the pins again to re-use for PWM
 
foxleyboy
Newbie

Joined: 09/06/2019
Location: United Kingdom
Posts: 20
Posted: 08:07am 15 Jun 2024
Copy link to clipboard 
Print this post

Thanks guys, Now tested both methods and it all works.
Maybe there should be something about this in the picomite user manual? Perhaps where the 'commands' are listed and defined? Certainly have not spotted it anywhere myself. Just a thought?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6027
Posted: 08:30am 15 Jun 2024
Copy link to clipboard 
Print this post

For SETPIN in the PWM section it says:
  Quote  Allocate pin to PWMnx. n and x are optional.
'n' is the PWM number (0 to 7) and 'x' and is the channel (A or B)
The setpin can be changed until the PWM command is issued. At that point
the pin becomes locked to PWM until PWMn,OFF is issued.


Although it's not specifically stated that the pin is released, it does make sense. After a while you start to assume this sort of thing as the manual can't really show every variation of every command.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


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

© JAQ Software 2024