[Open_electroporator] Timers, PWM, low-level MCU setup

Nathan McCorkle nmz787 at gmail.com
Mon Mar 20 07:35:42 UTC 2017


On Fri, Mar 17, 2017 at 2:10 PM, John Griessen <john at cibolo.com> wrote:
> What pulse period can you do? I was having trouble when I got down to 10 usecs

I was actually only testing about 10X in either direction, from the
period you had set in the original code you sent me.

When I tried going down to 10 usecs, after your last email, I started
seeing weird stuff... but I was able to clean up the code to get it
down to a single interrupt function now with no width or
period/duty-cycle glitching... EXCEPT when the period is around 10
usecs I am seeing an extra pair of pulses /sometimes/ being emitted.


That said, the code you originally sent me was set to a period of 920
usecs, and a width of 184 usecs.
So in that range of values, the (up to) 8.7 usec of variable delay
between the end of the one-pulse-mode train and the interrupts
function is a non-issue


As far as I can tell, this seems to be due to the Timer interrupt
priority not being as important as something else, which I am guessing
might be UART. I am not sure what else is running, maybe some timer
for the micropython helper 'delay' function, etc.
I just posted a question with a pared-down example of one-pulse mode
with a callback/interrupt function, so hopefully I'll figure out a way
to make this Timer function the top-priority interrupt and we won't
see any extra pulse pairs down at the low end :)

Another route, that would require some math during period/width
adjustment... could be the use of 'gated' mode... where the one-pulse
timer directly clocks the slave PWM-GPIO timers... so when the
one-pulse timer shuts off, the slaves do too, immediately.
TIM1 is a 16 bit register though, so it would limit flexibility, and
I'd bet we'd run into it pretty quick.

I feel like you had a way to disable the UART/repl... and re-enable
it? Maybe that would solve the issue.
That would then just leave us to figure out how to orchestrate
shipping ADC readings while pulsing, otherwise we'd need to buffer it
all in memory.


More information about the open_electroporator mailing list