Unkown Error in trying to initate PWM
# help
a
HI guys, just trying to get set up with Toit right now. I've loaded up the example pwm script, but it's throwing an UNKNOWN ERROR 0x102(258). I know the Pin is correct (it works with the basic standard led blink script), and is pwm compatible (from upython and arduino projects). I'm using a seeed XIAO esp3-c3, GPIO#10
Copy code
import gpio
import gpio.pwm

main:
  led := gpio.Pin 10
  generator := pwm.Pwm --frequency=50
  channel := generator.start led
  //channel.set-duty-factor 0.5
  sleep --ms=10_000
  channel.close
  generator.close
  led.close
And the monitor outputs: `[jaguar] INFO: program aecc3774-fdf7-fc6a-1e25-b3c397b6481f started E (2734368) ledc: freq_hz=1000 duty_resolution=16 ****************************************************************************** Decoding by
jag
, device has version ****************************************************************************** EXCEPTION error. UNKNOWN ERROR 0x102(258) 0: pwm-init_ \gpio\pwm.toit:177:3 1: Pwm \gpio\pwm.toit:103:12 2: main led_pwm.toit:6:16 ****************************************************************************** [jaguar] ERROR: program aecc3774-fdf7-fc6a-1e25-b3c397b6481f stopped - exit code 1`
f
We might be doing something wrong ok the C3... 😦
We are trying to find one, but we might only have them at the office ..
a
Haha, I'm not surprised. I know using the fringe boards makes things like this harder. Thanks for the help
f
I'm currently not at the computer but I will later look at the code and try to see if something obvious is wrong.
a
Very cool, thank you. I'll play around with the BLE until then
FYI, turning up the frequency to 10kHz got it working. For my use case I want to work in the 9-36Hz range, but I guess I can make that work with on/off timers and tasks.
f
You should be able to handle 9-36hz in software. Yes
What are you trying to drive with the pin? Maybe there is another good way?
a
Blinking LEDs. THe most basic of functions 🙃 (LEDs are 3W, so their being driven by a PNP transistor). I wanted to use the PWM to have non-locking functions for BLE control (change frequency, brightness etc). I just discovered the tasks which seem like a slightly more advanced asyncio function from upython though, which may be able to handle my use case for now
f
Why do you want to run it at such a low frequency?
a
It's a flicker-light stimulation device for brain wave entrainment. The effective studied frequenceies are 9-36Hz.
f
Ok. That makes more sense 🙂
If you need very precise timings it might be worth looking whether the i2s can be run at this low speed.
(probably not, but you worth checking).
a
My guess is that the brain is too slow for that level of precision, we already have an auto-correcting 80ms 'synchronization window' of stimuli. But I'll explore that option if the first round of tests turns out promising.
5 Views