Search found 45 matches

by bittware
Sun Jun 26, 2022 12:27 am
Forum: MicroPython pyboard
Topic: Is it possible to query Timer output?
Replies: 2
Views: 21349

Re: Is it possible to query Timer output?

The counter() function: https://docs.micropython.org/en/latest/library/pyb.Timer.html#pyb.Timer.counter should return the value of the timer counter (in particular the TIMx_CNT register). I think that you can also read the corresponding GPIO pin (if you're trying to read say CH3 from Timer 4 (pin Y...
by bittware
Sat Jun 25, 2022 9:26 am
Forum: MicroPython pyboard
Topic: Is it possible to query Timer output?
Replies: 2
Views: 21349

Is it possible to query Timer output?

I checked the API about the Timer class. It seems there is no direct method that could query Timer output state. If this is the case, then I have to have one extra digital input hooked to the timer output in order to read back the Timer output current state, either 0 or 1 at the querying time. My hu...
by bittware
Fri Jun 10, 2022 1:29 pm
Forum: MicroPython pyboard
Topic: External trigger to ADC
Replies: 8
Views: 26326

Re: External trigger to ADC

The reference manual of the stm32F405, chapter 13.7, states: a 12 Bit ADC conversion takes 15 clock cycles. Wow, this is critical information. Thanks for the correction. By referring to the section 13.6 Conversion on external trigger and trigger polarity of the manual, I found there is a possible r...
by bittware
Fri Jun 10, 2022 1:01 pm
Forum: MicroPython pyboard
Topic: External trigger to ADC
Replies: 8
Views: 26326

Re: External trigger to ADC

The sampling clock is internal and configured by the firmware. I would have to dig into the sources myself to tell, at which frequency. But let's say, it's 15 MHz. The conversion of of a 12 Bit ADC value takes at least 12 cycles of this clock, so the whole conversion takes about 1 µs, once started....
by bittware
Fri Jun 10, 2022 11:42 am
Forum: MicroPython pyboard
Topic: External trigger to ADC
Replies: 8
Views: 26326

Re: External trigger to ADC

Pin.irq is triggered by an external event. There is no internal timer, just some constant internal handling time. Whether that delay is acceptable for you, depends on your needs. The pin-irq latency is a few µs, until the handler starts executing. So I assume that you wil end up with a total latenc...
by bittware
Fri Jun 10, 2022 10:48 am
Forum: MicroPython pyboard
Topic: External trigger to ADC
Replies: 8
Views: 26326

Re: External trigger to ADC

You can use Pin.irq and call ADC in the handler. When using a hard irq, the latency is constant with Pyboard and just a few.us. So the sampling rate still relies on the internal timer? Can the ADC conversion be done on a per trigger basis? I need to sample and hold just once following the trigger e...
by bittware
Fri Jun 10, 2022 10:27 am
Forum: MicroPython pyboard
Topic: External trigger to ADC
Replies: 8
Views: 26326

External trigger to ADC

Hello
Is it possible to use an external trigger source to initiate ADC conversion on pyboard?
It seems that micropython only supports the internal timer as the ADC conversion clock. Is it correct?
by bittware
Thu Jun 02, 2022 7:45 am
Forum: MicroPython pyboard
Topic: Possible to change PA15 assignment?
Replies: 1
Views: 20157

Possible to change PA15 assignment?

Hi I'd like to find out an extra timer input. PA15 is a candidate that provides input to TIM2_CH1. But its already assigned to the yellow LED driver output within pyboard 1.1 context. I want to know if it's possible to reassign the pin function of PA15 assuming I use it as an input pin? Any side eff...
by bittware
Thu Jun 02, 2022 7:28 am
Forum: MicroPython pyboard
Topic: Why the encoder counting down?
Replies: 3
Views: 21883

Re: Why the encoder counting down?

I think I've found why.
You need to have the other pin-pair in fixed state to make sure the counting direction is determined.
If so, the other pin-pair needs to be reserved instead of being used for other purpose as it could bring up random state when the counting starts.
by bittware
Thu Jun 02, 2022 6:09 am
Forum: MicroPython pyboard
Topic: Why the encoder counting down?
Replies: 3
Views: 21883

Re: Why the encoder counting down?

If you swap the wires of the encoder, the counting direction will change. Yes, it's true. But why is that? I tried x_cnt = Pin(Pin.cpu.A1, Pin.AF_PP, pull=Pin.PULL_DOWN, af=Pin.AF2_TIM5) x_timer = Timer(5, prescaler=1, period=0x3fffffff) x_channel = x_timer.channel(1, Timer.ENC_B) # The channel num...