timer interrupts -- tim1 triggers tim3

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

timer interrupts -- tim1 triggers tim3

Post by jgriessen » Fri Aug 05, 2016 4:28 pm

I'm getting confused with all the cross references reading the STM32F401 datasheet, class Timer docs, code examples.

I am wanting to create pulses on two different pins that are exactly the same width,
and within 1 usec of the same spacing apart. That much should be single shot
so pulses don't continue after calling for pairs of them.

I'm going to make that function with variable spacing apart
and it will look like PWM but not go forever. There will be a
half_cycle_time counting along, at the new start of half_cycle_time a pulse starts on output1,
and after xfmr_pulse_w that ends with a Timer.OC_INACTIVE on output1. Next start of half_cycle_time a pulse starts on output2
and ends with a Timer.OC_INACTIVE.

I could use code and a Timer.OC_FORCED_ACTIVE to start pulse, or use machine code to set registers
for chaining one timer to another's input.

I'll start with the code way. Probably put off the chaining way for a good while.

I guess that will look like:

Set up a half_cycle_time timer interrupt. Still researching this one...does PWM trigger interrupts?
Does OC mode repeat or go once?

When in the callback routine, start another OC timer xfmr_pulse_w pulse,
figure which output1 or output2 to do next by global flags, exit
The OC timer xfmr_pulse_w pulse has no callback, just the output.
wait for next half_cycle_time timer interrupt.

The part figure which output1 or output2 to do next by global flags
is what I'm researching now.

John Griessen
John Griessen blog.kitmatic.com

Post Reply