TIM 2 used while booting m4?

When i flash my arduino Giga with 1 MB on M7 and 1 MB on M4, then boot the m4 using bootM4() and then print out the prescaler of timer TIM2, it is set to 239 (and a few other registers of TIM2 as well).

Is this intended? I could not find out why this is happening.

Steps to reproduce:

  1. use blink script example sketch, select 1MB flash split in arduino IDE and flash to M4 co-processor.
  2. use the following script and flash it with same memory split on M7:
#include <Arduino.h>

extern "C" uint32_t SystemCoreClock;

void setup() {
  Serial.begin(115200);
  bootM4();
   delay(4000); // important, takes a bit to take effect
  Serial.println(TIM2->PSC);
}
void loop() {
}

Expected result: TIM2->PSC should be 0

Actual result: TIM2->PSC is 239

Any idea what is going on here? Can I safely use TIM 2 for different purposes? I planned on using it in encoder mode to process a quadrature encoder.
So far, reconfiguring TIM 2 seems to work but I would like to have some clarity in order to not have my back bitten by this down the line.

Hi @tviehmann TIM2 is defined for us_ticker on M4 here ArduinoCore-mbed/cores/arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/us_ticker_data.h at main · arduino/ArduinoCore-mbed · GitHub

1 Like

ah, that makes sense, thank you! In case someone else finds this, it also affects TIM5 for us_ticker on M7, good to know in case you plan to use them.

curious if you found a simple way to disable the us_ticker config that takes over these two timers. i would like to have them back for my own purposes if possible.
thanks,
Jeff

No, we have not looked into it further. We considered to patch the mbed os variant to use a timer that is not physically exposed on the giga, which at first glance looked kinda straightforward (but those also have less capabilities and I am not sure if this would cause issues somewhere). However, this adds significant complexity to our deployment and therefore we did not pursue this further.