cancel
Showing results for 
Search instead for 
Did you mean: 

Find STM32 with 5 encoders input timers,

Vidicon
Associate II

For a project, I need to find a stm32 that has a minimum of 5 timers that can read encoders, and it has to have a CAN-bus peripheral.

Is there a way to do this in the part selectors? I can select the minimum number of 16bit timers, but not all 16bit counters seem to support encoder input. Any way to do this without manually reading all the datasheets?

I did try to automate this using the XML files in the data folder of stm32cube, but I did not really find a way to detect if a 16bit counter support encoder input.

17 REPLIES 17

@Vidicon wrote:

Mostly yes,
but it does not mention encoder mode for the Advanced-control timers TIM1, TIM8.


 

AN4013 suggests that 'Advanced' Timers can do everything that 'General-Purpose' Timers can do, and it says that includes the Encoder mode.

But, indeed, the Datasheet says that only some 'General-Purpose' Timers (TIM2-5) have the Encoder mode:

 AndrewNeil_0-1708344135844.png 

and the description of 'Advanced' timers is unhelpful:

 AndrewNeil_1-1708344213766.png 

 

 

Another 'Documentation Clarification' request for @STOne-32 and @Imen.D 

https://community.st.com/t5/stm32-mcus-products/what-s-the-value-of-efforts-towards-better-documentation/m-p/641075#M235854

 

I don't know where cube gets this information from,

In the timer xmls in IP subdirectory you'll find something like:

<Mode Name="Encoder_Interface" UserName="Encoder Mode" RemoveCondition="($IpNumber=6)|($IpNumber=7)|($IpNumber=18)|($IpNumber=9)|($IpNumber=10)|($IpNumber=11)|($IpNumber=12)|($IpNumber=13)|($IpNumber=14)|($IpNumber=15)|($IpNumber=16)|($IpNumber=17)">

note the RemoveCondition tag, i.e. this is list of timers (timers' numbers) which don't have encoder mode. Others do.

 

otherwise I could write a script to list all devices with 5 or more timers with the encoder mode.

If you do, please publish.

JW

RM0090 17.2 TIM1 and TIM8 main feature:
...

• Supports incremental (quadrature) encoder and hall-sensor circuitry for positioning
purposes

 

You should also have a look at AN4013


@Uwe Bonnes wrote:

You should also have a look at AN4013


That's the one I've been citing - it seems not entirely helpful:

AN4013 suggests that 'Advanced' Timers can do everything that 'General-Purpose' Timers can do, and it says that includes the Encoder mode.
But, indeed, the Datasheet says that only some 'General-Purpose' Timers (TIM2-5) have the Encoder mode

https://community.st.com/t5/stm32-mcus-products/find-stm32-with-5-encoders-input-timers/m-p/641294/highlight/true#M235911

:frowning_face:

Ow this is useful to know, I don't have time to write a full script to parse this today, but definitely something i want to do that in the future. 

Vidicon
Associate II

I did create this simple script:

 

import os
import xml.etree.ElementTree as ET
from pprint import pprint

def list_timers_in_mcu_files(directory):
    instance_names = {}
    for filename in os.listdir(directory):
        if filename.endswith('.xml') and filename.startswith('STM32'):
            tree = ET.parse(os.path.join(directory, filename))
            root = tree.getroot()
            instance_names.update({filename: []})
            timers = []
            for element in root:
                instance_name = element.attrib.get('InstanceName')
                if instance_name is not None and 'TIM' in instance_name:
                    timers.append(instance_name)
            instance_names[filename] = timers

    return instance_names

directory = 'mcu'
instance_names = list_timers_in_mcu_files(directory)
pprint(instance_names)

 

 It lists the timers per MCU (file), Now I have to look for an MCU that has the Timers that I need. 
There are some nice tables in AN4013.

Uwe Bonnes
Principal III

Nice script! IRTIM should get excluded. As suspected, U5 devices offer a lot of possible usefull devices.

Some LPTIM in some STM32 have encoder mode, too, IIRC. I have no personal experience.

JW