cancel
Showing results for 
Search instead for 
Did you mean: 

Solution architecture help

DJ001
Associate II

I need help in implementing a solution. I'd like to implement a system that measures elapsed time (ET) between two digital input (DI) pulses. These two signals will be on different channels. There are 4 sets of signal, therefore I need to measure four things: ET(0) = DI(0) -> DI(1), ET(1) = DI(2) -> DI(3), ET(2) = DI(4) -> DI(5), ET(4) = DI(6) -> DI(7).

The counting should be between positive edges, resolution should be in microseconds, maximum time will be <= 2s. Each of the measurements should reset on DI(x) and store on DI(x+1). It is possible that multiple DI(x) will occur before DI(x+1) therefore ET will always be the measurement between DI(x+1) and the last DI(X)

I first implemented a solution with a raspberry pi pico. That solution implemented an interrupt on each of the digital input channels that triggered on a positive transition. The interrupt handler essentially queues up the DI index and a 64bit microsecond tick count on a pre initialized queue. The super loop monitors the queue and figures out the elapsed times based on what comes through the queue.

For a number of reasons it's desirable to move to the STM32 foamily. In this case the L432KC was selected because of its form factor and its inclusion of a CAN peripheral.

Could someone offer any suggestions no how to approach this problem with the L432KC? Additionally, I'd be willing to move to a different family member if there is a compelling reason.

Thanks for the help

1 ACCEPTED SOLUTION

Accepted Solutions
DJ001
Associate II

Thanks for the note on this. I obviously have more reading to do. I've come across "AN4776 General-purpose timer cookbook for STM32 microcontrollers" that hopefully will help me wrap my head around the various options

View solution in original post

6 REPLIES 6
gbm
Lead III

Two 4-channel timers, possibly synchronized, capture mode. If you really need 32-bit resolution, use TIM2 and TIM5.

DJ001
Associate II

Thanks for the clue. This is great! The capture mode functionality seems to be what I'm after. Now I know where to focus my studies... Looks like we'll need to move up to a NUCLEO-G474RE to get the timers and CAN.

S.Ma
Principal

Also take note that some chips have a dma which can store capture valuee in a ram buffer, if you like to reduce interrupt frequency. A bit more advanced.

DJ001
Associate II

Thanks for the note on this. I obviously have more reading to do. I've come across "AN4776 General-purpose timer cookbook for STM32 microcontrollers" that hopefully will help me wrap my head around the various options

Piranha
Chief II

F3, H7 and G4 series also have a HRTIM peripheral with a plenty of timer instances. Though, if I'm not mistaken, those timers are 16-bit and therefore the software would have to count the overflows. Anyway, AN4539 provides more information about it.

DJ001
Associate II

Thank you