|
Forum Index : Microcontroller and PC projects : I may have found a bug.
| Author | Message | ||||
| cosmic frog Guru Joined: 09/02/2012 Location: United KingdomPosts: 302 |
On the 28 pin Micromite I'm using PWM 2,freq,2A. This should send a frequency to Pin26. If I added ,2B (ie. PWM 2,freq,2A,2B) this should send a frequency to Pin26 and Pin24. I seem to be getting something on Pin24 just by using 2A. I know this because I have a 16x2 LCD connected to this pin and when I send a frequency to Pin26 it effects Pin 24 and corrupts the display. From page 44 of the manual- "The specified I/O pin will be automatically configured as outputs while any others will be unaffected and can be used for other duties." I'm using v5.05.02 Thanks. Dave. Edited 2020-04-20 18:00 by cosmic frog |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
Hi cosmic PWM 2B use pin24 for output. for that, you send "something" on this pin when you declare PWM2B |
||||
| cosmic frog Guru Joined: 09/02/2012 Location: United KingdomPosts: 302 |
Hi Goc. I am only sending output to 2A (pin26) I'm not sending anything to 2B (pin24) Thanks. Dave. |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
but you put "PWM 2,freq,2A,2B" in your prog in this case proc send pulses on pin 26 and pin 24 (with same freq and same cycle) |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10577 |
I've checked the code and no apparent bug Try the following Connect pin 24 to pin 15 and run the code: SETPIN 15,CIN,PULLUP PWM 2,1000,50 PAUSE 1000 PRINT PIN(15) |
||||
| cosmic frog Guru Joined: 09/02/2012 Location: United KingdomPosts: 302 |
You need to re-read my post. |
||||
| cosmic frog Guru Joined: 09/02/2012 Location: United KingdomPosts: 302 |
Try the following Connect pin 24 to pin 15 and run the code: SETPIN 15,CIN,PULLUP PWM 2,1000,50 PAUSE 1000 PRINT PIN(15) I'll give it a try. Thanks. |
||||
| panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1116 |
@cosmic frog, I can not see any issue with any crosstalk between the two outputs of PWM channel 2 on a 28 Micromite running 5.05.02. Have you checked that you don't have either a short somewhere between pins 24 and 26? The only issue I can see is that once a PWM channel starts, it continues to output until a PWM channel,STOP is issued. So, if for example, you issue the command PWM 2,1000,50,30 ... you get a 50% square wave on pin 26 (2A) and a 30% (2B) square wave on pin 24, which is of course, correct operation. If you now decide to use the first output (pin 26 or 2A) only for PWM and now issue the command PWM 2,1000,10 ... you get a 10% sqaure wave on pin 26 but the output on pin 24 (the 30% square wave) continues until you either reset the MM or issue a PWM 2,STOP command. Note that this will kill BOTH 2A and 2B outputs (pins 26 and 24 respectively). As an aside, there does not appear to be a way to utilise the 2B output only as the command PWM 2,1000,,50 throws a syntax error. So a question for Geoff or Peter is, how can the second output of PWM channel 2 on pin 24 (2B) be utilised for PWM action while using the primary output (2A on pin 26) for some other I/O function? panky ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
| cosmic frog Guru Joined: 09/02/2012 Location: United KingdomPosts: 302 |
Hi Panky and thanks for the reply. Just been doing some more tests and found that the 'bug' happens when you use PWM 2,STOP. So there is no signal on pin24 with PWM 2,freq,50 but if I try to stop it with PWM 2,STOP I see corruption on my LCD. The workaround for this is to use something like PWM 2,90000,0 insted of PWM 2,STOP. I think what is happening is, it assigns pins 26 and 24 with PWM 2 and with PWM 2,STOP it releases the pins back to a undetermined state, corrupting the LCD. Maybe? Thanks. Dave. Edit. Just putting PWM 2,STOP in my program corrupts the LCD. Edited 2020-04-21 18:21 by cosmic frog |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10577 |
This does look like a bug in PWM stop- I'll email Geoff |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
Hi is it possible that it is same pb as I have with digital pot and values not correct ?? (see https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12049&LastEntry=Y#145116) |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10577 |
Only if you are using PWM pins other than the first one for a specific purpose and have issued a PWM STOP command for that channel |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
Only if you are using PWM pins other than the first one for a specific purpose and have issued a PWM STOP command for that channel Sorry but I have changed my CS pin (pin22 in place of pin26). and I have same problème |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
Only if you are using PWM pins other than the first one for a specific purpose and have issued a PWM STOP command for that channel I found the origin of my value imprecision problem with digital pot. this comes from the fact that I had not wired the 8Mghz quartz (with 2x22pf), so everything was more or less unstable. With quartz it became correct |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
Sorry, I just discovered this question. The answer is that you cannot. You must use 2A first, then 2B can be used or not. Geoff Geoff Graham - http://geoffg.net |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |