Hardware interrupts on PORTENTA H7?

Hello fellow "micro-controller enthusiasts"

I just recieved arduino Portenta H7 a few days back, and have first sketches running on it..

I stumbled upon strange issue regarding hardware timers..

I can not get hardware timers to work with arduino IDE..
I have tried multiple libraries, and always get "Error compiling for board Arduino portenta h7"..

I have also tried libraries that are made for running on mbed OS microcontrollers (nano 33 BLE, portenta..) and it still does not want to work (outputs same error)..

Have any one of you guys managed to get hardware timers running on portenta board?
I would really appreachiate any feedback, examples..

Have a great day!

Most STM32 MCUs have two basic timers, TIM6 and TIM7. I have the following code for an STM32F4.

Give it a shot

initialize TIMER6

void periphInit_TIM6(void)
{
	// enable TIM6 clock
	RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;

	// set TIM6 prescaler for 1 MHz operation [90 MHz / 90]
	TIM6->PSC = 90 - 1;

	// set initial TOP value to generate 1500 us
	TIM6->ARR = 1500;

	// disable DMA or interrupt generation
	TIM6->DIER = 0<<TIM_DIER_UDE_Pos | 0<<TIM_DIER_UIE_Pos;

	// initiate update of registers
	TIM6->EGR = TIM_EGR_UG;

	// clear flag
	TIM6->SR = 0;

	return;
}

use TIMER6 to generate delays

void delay_us(uint16_t usec)
{
	// set TOP value
	TIM6->ARR = usec;

	// start one-pulse timer mode
	TIM6->CR1 = TIM_CR1_OPM | TIM_CR1_URS | TIM_CR1_CEN;

	// wait to TOP
	while((TIM6->SR & TIM_SR_UIF_Msk) == 0);

	// clear flag
	TIM6->SR = 0;

	return;
}

void delay_ms(uint16_t msec)
{
	for(uint16_t count=0; count<msec; count++) {
		delay_us(1000);
	}

	return;
}

This is based on a 90 MHz peripheral clock so the delay may be wrong if yours run on a different clock.

Use this newly created Portenta_H7_TimerInterrupt Library