iMX7 M4 timers in FreeRTOS

Hi,

I am planning to use FreeRTOS on the M4 to switch a GPIO with configurable time intervals. All i need is a high resolution timer. SW timer are working, but the resolution is way too low. Now i have read that there are GPTs available.
Where can i find documentation about those timers?
How many timers are available (it looks like two)?
What would be the highest resolution possible?
Does Linux use one or more of the GPTs?

You can find the documentation in the i.MX 7Dual Application Processors Reference Manual (available from NXP website).

There are four instances (GPT1-4).

By default the internal clock of 24Mhz is used. There are options to also use external clocks, but they seem to be limited to 1/4 of the peripheral clock (which is 67.5MHz).

The default device tree enables the first GPT1 in the imx7s.dtsi device tree. Linux does initialize the timer during startup:

clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns

However, the timer is not actually used, Linux uses the ARM architected timer, as noted by a later boot log entry:

Switched to clocksource arch_sys_counter

So you can safely disable the use of the GPT1 timer in Linux by adding status = "disabled"; in the gpt1 node. Or just use any of the three other timers.

Thanks for the information.
According to the header file “freertos-colibri-imx7/platform/drivers/inc/gpt.h” there are three output compare register per timer? So i could use one timer to switch three GPIOs at specific (relative) times?

As far as I understand yes. Check the Colibri iMX7 whether all three pins are available on the SODIMM connector (Chapter 4.4 Functions List).

I reserved GPIO bank 4 for the M4, so i should be able to use pins 11-14 (X9) on the Viola board as GPIOs. The timers itself should not need pins at all?

No you cannot use any random GPIO for output compare. The output GPIO which will be controlled by the output compare channels are predefined and need to be muxed accordingly (see e.g. gpt1.COMPARE1 gpt1.COMPARE2 and gpt1.COMPARE3 in the Colibri iMX7 Datasheet).

Unless you use just an interrupt and toggle GPIO in software, in that case you are free to use any GPIO of course.