Yeah, that's me. I figured I should use my real name for GitHub, but I don't really want to use it as my forum name. Too much seeing my own name everywhere (plus, I'm used to people I know online calling me Azzy).
Oh! I wish I'd known about those tooltips on the Espruino pinout diagram.
Gordon, I can't reconcile the conflicts reported with your statement that the Espruino chooses the first option. For example, A7 and C6 fight - presumably over TIM8_CH1 - but I would have expected A7 to grab TIM1_CH1N...
Is it necessary that the timers are connected to the pins in order to use SPI? B13~15 (SPI2) doesn't work if you've used the PWM on A8~A10 - but I can't seem to produce an analogous problem with the other sets of pins , which makes me wonder if this has to be this way.
Also, it seems like some changes to how the Espruino chooses which timer to use would yield considerable improvements in behavior here, assuming there isn't some further complication.
For example: C6~C9 are the only pins that can use TIM8. So they should always use TIM8 for PWM, and never use TIM3 (which is shared with multiple other banks of pins), and A6~B1 should never use the TIM8_CH*N channels.
Likewise, A0~A3 are the only pins that can use TIM5 - they should use it, leaving TIM2 totally to B5, B10, B11.
And that leaves TIM3 for A6,A7,B0,B1
Now B4, B5 wouldn't have a TIM3 to use, but that's okay, because they're SPI1/3 MOSI and MISO, which will usually be used for an SPI device (usually the network controller), not PWM output.
B13~15 would also not have their TIM1_CH*N's, but those pins are used for the SD card, which most people would want to keep available.
If B13~15 can be unhooked from TIM1_CH*N, then that would free up A8, A9, A10 for use as PWM without clobbering SPI2 (and thus the SD card) - though per that github issue, A9 doesn't work out of the box (I've seen that poke to fix it, but I haven't tried it)....
Thus we'd be left with 19 (-1 if using SPI3/1, -2 if using SPI1) PWM pins that can all work at the same time (22 if A8~10 can be made usable) without clobbering anything important or fighting with eachother, versus the current 15 simultaneously-usable PWM pins.
Does digitalPulse() use the same hardware timers that PWM does?
Edit: Sounds like digitalPulse() does...? From my brief reading of that scary tome from STM.
It seems like a lot of the issues are due to the negations of the PWM being output from TIM1/TIM8 (that was what I had earlier called unpredictable behavior). It looks like it should be possible to turn these off with peek/poke - but peek() doesn't seem to be working for me, so I wasn't able to get any farther (see other thread on that).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yeah, that's me. I figured I should use my real name for GitHub, but I don't really want to use it as my forum name. Too much seeing my own name everywhere (plus, I'm used to people I know online calling me Azzy).
Oh! I wish I'd known about those tooltips on the Espruino pinout diagram.
Gordon, I can't reconcile the conflicts reported with your statement that the Espruino chooses the first option. For example, A7 and C6 fight - presumably over TIM8_CH1 - but I would have expected A7 to grab TIM1_CH1N...
Is it necessary that the timers are connected to the pins in order to use SPI? B13~15 (SPI2) doesn't work if you've used the PWM on A8~A10 - but I can't seem to produce an analogous problem with the other sets of pins , which makes me wonder if this has to be this way.
Also, it seems like some changes to how the Espruino chooses which timer to use would yield considerable improvements in behavior here, assuming there isn't some further complication.
For example: C6~C9 are the only pins that can use TIM8. So they should always use TIM8 for PWM, and never use TIM3 (which is shared with multiple other banks of pins), and A6~B1 should never use the TIM8_CH*N channels.
Likewise, A0~A3 are the only pins that can use TIM5 - they should use it, leaving TIM2 totally to B5, B10, B11.
And that leaves TIM3 for A6,A7,B0,B1
Now B4, B5 wouldn't have a TIM3 to use, but that's okay, because they're SPI1/3 MOSI and MISO, which will usually be used for an SPI device (usually the network controller), not PWM output.
B13~15 would also not have their TIM1_CH*N's, but those pins are used for the SD card, which most people would want to keep available.
If B13~15 can be unhooked from TIM1_CH*N, then that would free up A8, A9, A10 for use as PWM without clobbering SPI2 (and thus the SD card) - though per that github issue, A9 doesn't work out of the box (I've seen that poke to fix it, but I haven't tried it)....
Thus we'd be left with 19 (-1 if using SPI3/1, -2 if using SPI1) PWM pins that can all work at the same time (22 if A8~10 can be made usable) without clobbering anything important or fighting with eachother, versus the current 15 simultaneously-usable PWM pins.
Does digitalPulse() use the same hardware timers that PWM does?
Edit: Sounds like digitalPulse() does...? From my brief reading of that scary tome from STM.
It seems like a lot of the issues are due to the negations of the PWM being output from TIM1/TIM8 (that was what I had earlier called unpredictable behavior). It looks like it should be possible to turn these off with peek/poke - but peek() doesn't seem to be working for me, so I wasn't able to get any farther (see other thread on that).