STM32L431RBT6 - trigger timer from EXTI? Or generic pin? - Page 1
Forum section: electronics / general

author: daqq
author_rank: Super Contributor
timestamp: July 04, 2022, 11:08:31 am
content: Hi,In a project I need to trigger a timer (any will do) from a specific pin (PA7) on the STM32L431RBT6. I think I read somewhere that you can start/trigger a timer from EXTI or an event, but I can't find it anywhere. Is this just a case of me misremembering, or is it just really hard to find?Something more direct than just use the EXTI interrupt, jump into it, software start the timer, leave.Ideally the pin would have been routed onto a normal input - and it was, but the MCU used originally is unavailable and the only pin-compatible replacement that is borderline available does not have a timer channel on that location.Thanks,David

author: wek
author_rank: Frequent Contributor
timestamp: July 04, 2022, 02:39:07 pm
content: Ahoj,> Is this just a case of me misrememberingMost likely this.> Something more direct than just use the EXTI interrupt, jump into it, software start the timer, leave.Analog watchdog on ADC1_IN12 won't count as "more direct", I'm afraid...> borderline availableOh, so that was YOU who bought these out! :-)I feel your pain.JW

author: daqq
author_rank: Super Contributor
timestamp: July 06, 2022, 08:48:38 am
content: Thanks, thought as muchQuoteNot me, but I know the company that bought out a certain other uC

author: wek
author_rank: Frequent Contributor
timestamp: July 06, 2022, 12:09:57 pm
content: Btw. I still believe the the analog watchdog pushed to extreme (6-bit conversion, shortest possible sampling - this is subject to experimentation due to PA7 being "slow" ADC input), triggering TIM1 through ETR_ADC1_RMP, is a viable option; of course depending on whether your application uses ADC1 in any other way or not.Latency is IMO comparable to EXTI - if 2.5tADC sampling time would be viable, a conversion is 9cyc but even with 6.5tADC sampling it's just 13cyc; plus whatever time it takes the ADC to perform the WD comparison and propagate the signal to TIM, but that IMO should be well below half a dozen, so that's say 15-20cyc. Unfortunately 9/13cyc of that is jitter, too.Conversely with EXTI, considering minimal hand-optimized-in-asm ISR running out of 0WS memory (RAM), latency is 12+longest_instruction+load_TIM_address+load_value_to_trigger_TIM+store_to_TIM, and that would be 15-20cyc :-). However, this assumes EXTI being of highest priority, and that there is no interrupt disable in the code. This is probably easier to write than the ADC_WD solution and allows any TIM to use, and the jitter will be lower, too; OTOH this is software with all the consequences.JW

author: daqq
author_rank: Super Contributor
timestamp: July 07, 2022, 06:29:04 am
content: I actually thought about using the ADC that way, but the ADC is already used.It'll be a challenge to write the assembly block that gets triggered that fast, but beggars can't be choosers. We'll see what's possible. But many thanks for the suggestions!

author: langwadt
author_rank: Super Contributor
timestamp: July 07, 2022, 07:32:48 am
content: any other pins avaible for a bodgewire? like a solder blob to PA6 ?

author: daqq
author_rank: Super Contributor
timestamp: July 07, 2022, 08:35:36 am
content: Quote from: langwadt on July 07, 2022, 07:32:48 amNot for the volumes that'll be used. We could redo the board - that would be trivial. But not as a first option.

author: Jeroen3
author_rank: Super Contributor
timestamp: July 07, 2022, 09:21:02 am
content: The EXTI isn't wired up to the timers.Your bad luck is having the TIM1_CH1Non the pin, when you short it to PA6 you can use TIM16_CH1 input capture.For PA7 you can only use the exti interrupt, EXTI9_5. What requirements do you have that you think this is not suitable?

author: enz
author_rank: Regular Contributor
timestamp: July 07, 2022, 09:22:28 am
content: Couldn't you just use the EXTI to trigger a DMA transfer that starts the timer?Should be the option with the lowest latency.Or do i miss omething?

author: Jeroen3
author_rank: Super Contributor
timestamp: July 07, 2022, 09:33:03 am
content: @enz Only EXTI9 can trigger the DMA, you have to go via the DAC, which is of no help because op uses a pin 7.EXTI7 is only connected to the ADC start conversion via (J)EXTSEL.

author: enz
author_rank: Regular Contributor
timestamp: July 07, 2022, 09:53:57 am
content: Uups, my bad.Somehow i rememberd that any EXTI could trigger a DMA transfer.Certainly not true.

author: wek
author_rank: Frequent Contributor
timestamp: July 07, 2022, 12:12:18 pm
content: Quote from: Jeroen3 on July 07, 2022, 09:33:03 amMy RM0394 lists only EXTI11 as EXT and EXTI15 as a JEXT option in the ADC chapter. Am I overlooking something?JW

author: Jeroen3
author_rank: Super Contributor
timestamp: July 07, 2022, 12:22:10 pm
content: Oh no wait, the ADC's calls it EXT (no I) and has a separate selector. Almost....