no debugging outputs from the code. It's as if the code is not being run.
Code: Select all
import pyb, micropython
micropython.alloc_emergency_exception_buf(100)
debug_pin = pyb.Pin('JP6', pyb.Pin.OUT_PP)
#Use with pyb.freq(96000000) and prescaler=11 for .125 usec timer ticks.
xfmr_pulse_period = 0x1F40 #(1000 usec * 8)-> hex
xfmr_pulse_w = 0xa0 #(20 usec * 8)-> hex
xfmr_pulse_pos_half-cycle = 1
#to give .125 usec timer ticks counting up:
t1 = pyb.Timer(1, prescaler=11, period=xfmr_pulse_period, mode=pyb.Timer.UP)
#xfmr_pulse_half-cycle timing. (for rollover callback)
#JP3 output -- just an interrrupt. Compare generates interrupt:
t1ch2 = t1.channel(2, pyb.Timer.OC_TOGGLE, compare=xfmr_pulse_period, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP3)
#xfmr_pulse_pos_half-cycle driver pin. (positive driving transistor)
#Control output pin JP5 active high. Compare turns off output pin at xfmr_pulse_w count:
t1ch1 = t1.channel(1, pyb.Timer.OC_INACTIVE, compare=xfmr_pulse_w, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP5)
#NOT(xfmr_pulse_pos_half-cycle) driver pin. (negative driving transistor)
#Control output pin JP4 active high. Compare turns off output pin at xfmr_pulse_w count:
t1ch3 = t1.channel(3, pyb.Timer.OC_INACTIVE, compare=xfmr_pulse_w, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP4)
def t1ch2_pulses_start_cb
global xfmr_pulse_pos_half-cycle
if xfmr_pulse_pos_half-cycle == 1:
#xfmr_pulse positive half-cycle off-time just ended
#turn on driver for following negative half-cycle
xfmr_pulse_pos_half-cycle = 0
t1ch1 = t1.channel(1, pyb.Timer.OC_FORCED_ACTIVE, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP5)
t1ch1 = t1.channel(1, pyb.Timer.OC_INACTIVE, compare=xfmr_pulse_w, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP5)
debug_pin.value(0)
debug_pin.value(1)
debug_pin.value(0)
#pyb.Pin.board.JP5.value(1)
else:
#xfmr_pulse negative half-cycle off-time just ended
#turn on driver for following positive half-cycle
xfmr_pulse_pos_half-cycle = 1
t1ch3 = t1.channel(3, mode=Timer.OC_FORCED_ACTIVE, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP4)
t1ch3 = t1.channel(3, pyb.Timer.OC_INACTIVE, compare=xfmr_pulse_w, polarity=pyb.Timer.HIGH, pin=pyb.Pin.board.JP4)
#pyb.Pin.board.JP4.value(1)
debug_pin.value(1)
debug_pin.value(0)
debug_pin.value(1)
t1ch2.callback(t1ch2_pulses_start_cb)
while True:
pyb.delay(1)
debug_pin.value(0)
pyb.delay(1)
debug_pin.value(1)
How do you use that error memory: micropython.alloc_emergency_exception_buf(100)
?
I still can get a repl after each reset, and still
can toggle a pin with code like:
pin3 = pyb.Pin('JP3', pyb.Pin.OUT_PP)
pin3.value(1)
JP4, JP5, JP6,JP3 all test out OK to change volt value after setting this way.
Perhaps the initialization is not complete on those as started up with the new platform file.
pin=pyb.Pin.board.JP4 and so on may not have all the needed data entered such as active HIGH...
pyb.freq() reports 96 96 24 48 MHz. I saw something about a limit on those...
I ran another program that Nathan ran OK and hooked up an LED to JP6 as if JP6 could only pull down
and nothing after reset.
My boot.py is:
cat /flash/boot.py
Code: Select all
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import machine
import pyb
pyb.freq(96000000)
pyb.main('min-test.py') # main script to run after this one
#pyb.usb_mode('CDC+MSC') # act as a serial and a storage device
#pyb.usb_mode('CDC+HID') # act as a serial device and a mouse
/home/john> cat /flash/min-test.py
Code: Select all
import pyb
from pyb import Timer
# timer 4 will be created with a frequency of 10 kHz
tim=pyb.Timer(4,freq=10000);
# attach the timer to the LED GPIO, turning the brightness OFF to begin
tchannel = tim.channel(3, Timer.PWM, pin=pyb.Pin.board.JP6, pulse_width_percent=8)
pyb.delay(70)
tchannel. pulse_width_percent=80)
pyb.delay(700)
tchannel. pulse_width_percent=30)
pyb.delay(700)
tchannel. pulse_width_percent=60)