I'd like to output PWM signals on the Hall1 (GPIOB pin 6) and Hall2 (GPIOB pin 7) pins of my hardware version 4.12 VESC. I know about the existing code that allows this to be done for addressable ws2811 LEDs, but I'd like to simply output a duty cycle between 0 and 3.3 V. I was thinking of essentially taking code from servo_simple, which outputs a servo on GPIOB pin 5 using TIM3, and adapting it to output PWMs on pins 6 and 7. Are there any obvious reasons as to why this wouldn't work?
servo_simple uses the pad setup command:
palSetPadMode(GPIOB, 5, PAL_MODE_ALTERNATE(GPIO_AF_TIM3) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUDR_FLOATING);
Would the same thing work for GPIOB pins 6 and 7? My concerns include:
- TIM3 may not be appropriate for pins 6 and 7, and maybe TIM4 (which is used for the ws2811 leds) should be used instead
- pins 6 and 7 may not be compatible with the mode " PAL_MODE_ALTERNATE(GPIO_AF_TIM3) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUDR_FLOATING "