AnsweredAssumed Answered

ARR and CCR update time

Question asked by Massimiliano Gilli on Jun 24, 2017
Latest reply on Jun 25, 2017 by avi_crak.videocrak

I need to vary the frequency and duty cycle of a pwm using stm32f401. Inside the "pulse finished" pwm callback i've tried the following code

HAL_GPIO_WritePin(LED5_PORT, LED5_PIN, GPIO_PIN_RESET);  //tentative 1 //TIM9->ARR = round(value); //TIM9->CCR1 = round(value) * 0.2; //tentative 2 //htim9.Instance->ARR = round(value); //htim9.Instance->CCR1 = round(value) * 0.2; //tentative 3 int *point = (int *) (TIM9_BASE + 0x2C); *point = round(value); int *point1 = (int *) (TIM9_BASE + 0x34); *point1 = round(value) *0.2; HAL_GPIO_WritePin(LED5_PORT, LED5_PIN, GPIO_PIN_SET);  

In all the 3 cases if i measure with an oscilloscope the amount of time that passes between the ON/OFF state of the LED5 the value is 6us. The ON/OFF state alone is 500ns.

I get the Update event thing and it is not a problem but this means that i'm waiting 5.5us for my function to return just for assigning those two register and so i'm limited in term of performance.

It is clear that i have a problem which im not seeing.

Any ideas?