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 KingdomPosts: 20 |
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: AustraliaPosts: 2135 |
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 KingdomPosts: 20 |
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 KingdomPosts: 9110 |
The above bug is fixed in the latest download |
||||
foxleyboy Newbie Joined: 09/06/2019 Location: United KingdomPosts: 20 |
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 KingdomPosts: 20 |
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: NetherlandsPosts: 4223 |
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 KingdomPosts: 20 |
Hi Volhout certainly setting it to a zero duty cycle works. Many thanks Roy |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9110 |
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 KingdomPosts: 20 |
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 KingdomPosts: 6783 |
For SETPIN in the PWM section it says: 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 |