pyb.Timer.PWM to generate an IR receiver test signal #16741
Unanswered
davefes
asked this question in
STM32 / Pyboard
Replies: 2 comments 1 reply
-
Found this link: def toggle():
import machine
pdsckPin = machine.Pin(4, machine.Pin.OUT, value=0)
isr = machine.disable_irq()
do_toggle()
machine.enable_irq(isr)
@micropython.viper
def do_toggle():
GPIO_OUT = ptr32(0x60000300) # GPIO base register
for i in range(100):
GPIO_OUT[1] = 0x10 # set bit 4
GPIO_OUT[2] = 0x10 # clear bit 4 This was done for the ESP8266, is it possible to do this on the STM32F411? Maybe better still "Accessing hardware directly" import machine
import stm
BIT14 = const(1 << 14)
machine.mem16[stm.GPIOA + stm.GPIO_ODR] ^= BIT14 |
Beta Was this translation helpful? Give feedback.
0 replies
-
No joy using Peter's micropython_ir? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using a WeACT F411 with the latest pre-release in a circuit that turns
an IR LED on and off at a 10% duty cycle.
According to the datasheet for the IR receiver TSOP4136 I should have about a
20 cycle on-period and a 10 cycle off-period, to achieve the "maximum number of
continuous short bursts/second to be less than 2000"
In an effort to try and control the on/off periods I modified the
while loop
:This runs, but I suspect that one might need to put in the exact times for the on/off periods or you will get some waveform distortion.
pyb.udelay()
will not accept floats.I do see the last on period, in the 20 cycles, vary in length and sometimes get dropped.
Appreciate any suggestions for the right way to get precise control of the
waveform to drive the IR LED.
Edit: Is there some way that you can tell when the last 10% duty cycle pulse finishes, ie by counting them and when you reach 20 then go to the off-period?
Beta Was this translation helpful? Give feedback.
All reactions