I don't know what I am doing wrong here and really would appreciate some help:
I created a function called
void DELAY_1_5us(uint16_t period)
delay = true;
this function uses TIM7 of the STM32F429ZI-DISC1 discovery board as a simple programmable timer for approx. x time 1,5µs delay. with the 16-Bit ARR value I get maximum 2^16 x 1,5µs delays because of the following init routine (84MHz/128 = 656,250kHz = 1,5238 µs counter tick):
htim7.Instance = TIM7;
htim7.Init.Prescaler = 128;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 1;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
In the ISR I just set the delay value so the while loop in the dely function is interrupted. The LCD_CS pin is just to measure the elapsed time on an oscilloscope.
/* USER CODE BEGIN TIM7_IRQn 0 */
delay = false;
/* USER CODE END TIM7_IRQn 0 */
/* USER CODE BEGIN TIM7_IRQn 1 */
/* USER CODE END TIM7_IRQn 1 */
The problem now is, that the function -regardless which value for the delay period of the DELAY_1_5_us functionI choose - the timer shows only approx. 1µs delay on the oscilloscope. I checked the register entry for TIM7_ARR and it changes with each function call. I also thought this might have to do something with the UG bit to generate an UE so that the timer loads the new ARR value.
But even with htim7.instance->EGR = 0x1 nothing is happening. Also when I try to activate the preload buffer with htim7.instance->CR1 |= 0x0080; nothing is changing in the appropriate reigisters.
I would really appreciate if someone could help me. I tried the code with ATOLLIC TrueStudio and SW4STM32 all set with optimize for debug.