Increasing the pwm frequency

Hello sir, @madcowswe this topic is regarding pwm frequency. I am currently using maxon bldc but i am not using its driver rather i am using odrive for it. But the problem is that maxon generally works on 50khz pwm frequency but the output frequency of odrive is 24khz max. So can i increase my odrive frequency by just changing the clock variable of arm pressure as mentioned in changelog or if i need to change it some where in the code also?

You need to change TIM_1_8_RCR in Board/v3/inc/main.h. The PWM frequency = 8kHz * (TIM_1_8_RCR + 1). So 0 gives 8kHz, 2 gives 24kHz, 4 gives 40kHz, and 6 gives 56kHz. You can only pick whole, even numbers for RCR.

Thanks for the reply @Wetmelon @madcowswe:
Will this be the sufficient , i mean the value of TIM_1_8_RCR is updated several times as mentioned in the link:
https://github.com/lalten/ODrive/commit/f2ea04daaae808047a8a0ae517dd8e4eef8d0d9b#diff-100759420a10412b3899279401ff7369R81.

And do i not need to change anything else and if the mos-fets have sufficient switching frequency?

Hope for a quick reply.

Hello sir, @madcowswe @Wetmelon
As you have mentioned, i have changed the variable TIM_1_8_RCR to 6 in order to make the frequency 56kHz but it did not changed the pwm frequency which i had measured from an oscilloscope. I had even changed TIM_1_8_RCR to 6 wherever mentioned in Boards/v3/inc as mentioned in
https://github.com/lalten/ODrive/commit/f2ea04daaae808047a8a0ae517dd8e4eef8d0d9b#diff-100759420a10412b3899279401ff7369R81 .

but it didn’t changed the frequency at all. I am successfully compiling and flashing the firmware in my O drive v3.5 .
When i make in the firmware directory this thing outputs in my firmware
[10.076s] arm-none-eabi-g++ -std=c++14 -c communication/communication.cpp -DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=5 -DHW_VERSION_VOLTAGE=24 -DUSB_PROTOCOL_NATIVE -DUART_PROTOCOL_ASCII -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F405xx -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wall -Wdouble-promotion -Wfloat-conversion -fdata-sections -ffunction-sections -g -gdwarf-2 -Og -ffast-math -fno-finite-math-only -IDrivers/DRV8301 -IMotorControl -Ifibre/cpp/include -I. -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/include -IBoard/v3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -IBoard/v3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -IBoard/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -IBoard/v3/Drivers/STM32F4xx_HAL_Driver/Inc -IBoard/v3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -IBoard/v3/Drivers/CMSIS/Device/ST/STM32F4xx/Include -IBoard/v3/Drivers/CMSIS/Include -IBoard/v3/Inc -I. -IDrivers/DRV8301 -o build/communication_communication.cpp.o In file included from Board/v3/Inc/stm32f4xx_hal_conf.h:43:0, from Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:46, from communication/interface_can.hpp:5, from communication/communication.cpp:8: Board/v3/Inc/main.h:172:53: warning: conversion to 'int' alters 'float' constant value [-Wfloat-conversion] #define CURRENT_MEAS_HZ ( (float)(TIM_1_8_CLOCK_HZ) / (float)(2*TIM_1_8_PERIOD_CLOCKS*(TIM_1_8_RCR+1)) ) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MotorControl/odrive_main.h:38:36: note: in expansion of macro 'CURRENT_MEAS_HZ' static const int current_meas_hz = CURRENT_MEAS_HZ; ^~~~~~~~~~~~~~~

Am i doing it in the correct way or i need to change some other variables too?
Please reply as soon as possible.
Thanks.