Setting analogWrite on B0 sets any analogWrite value of B4 to 0 #4425
Replies: 1 comment
-
Posted at 2015-02-15 by DrAzzy Expected hardware limitation - they both use TIM3. Stay away from PWM on B4/B5 those pins are TIM3 channel 1 and 2. You get 3 choices with TIM3 - it can be on A6A7B0B1, or it can be on B4 and B5 (and the other two channels aren't available - on versions of the chip with more pins, I think they are), or on C6-9 (but C6-9 have better alternatives for PWM, so TIM3 shouldn't get used for them) A while ago, this was much worse, but Gordon cleaned it up, so I don't think any pairs of PWM pins fight anymore, except B4/B5, which conflict with A6-B1. Now I think what Espruino uses is: TIM1 is on A8/9/10 - but IIRC you need to do something to shove the serial off A9/10 to use it on those pins, because it defaults to having Serial1 there so you can use bluetooth with it. TIM2 is on B10/B11 One could argue that Espruino should try to fish around for a better PWM channel if possible (ie you try to do analogWrite(B4); analogWrite(B0), but had nothing on TIM1 or TIM8 to use a negated channel, it'd use that) - but I think this would make the conflicts that still occurred much, much harder to debug. i don't understand the specific behavior you're seeing where they're somehow both on, though. Posted at 2015-02-15 by Alex Hi DrAzzy, At the moment I'm using 12 PWM's: B3,B4,B8,B9,A0,A1,B10,B1,B0,A3,A7,B11. If I'd move the B4 to A2, would that be OK then? Cheers! Posted at 2015-02-15 by DrAzzy Yeah, that should be good. It's just B4 or 5 with A6, A7, B0, or B1. (Oh - also: if you're specifying the frequency, it has to be the same for all channels on each timer - so if you do 200hz on A0, A1/2/3 will also be 200hz) Posted at 2015-02-16 by @gfwilliams Thanks for the answers @drazzy - yes, there's a bug open for trying to make the interpreter more intelligent about choosing timers, but you're still likely to hit problems. At least if it were smarter it would be able to tell you though. I'll add a note to the board's pinout page though that B4 and B5 aren't good PWM pins to use though. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-02-15 by Alex
Hi Gordon,
We've been playing around with the PWM's and after resoldering our docking station because B4 and A6 don't like eachother, we encountered a new problem.
We reduced it to this:
firmware v1.73:
Is this a hardware thing or is it in the firmware?
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions