大家好,我最近一个星期才开始接触STM32,在ST网站上下了一个[img]STM32F302R8的电机驱动代码模板,但是我看主函数里面就只进行了初始化,我得添加哪些函数才能让电机转起来啊?
下面是主函数
int main(void)
{
/* USER CODE BEGIN 1 */
#ifdef BOOT
SCB->VTOR = 0x08009A00; /* Change vector table */
#endif
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_DAC_Init();
MX_TIM1_Init();
MX_TIM6_Init();
MX_TIM16_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
/* ****************************************************************************
==============================================================================
###### This function initializes 6-Step lib ######
==============================================================================
**************************************************************************** */
MC_SixStep_INIT();
/****************************************************************************/
/* USER CODE END 2 */
/* USER CODE BEGIN 3 */
/*! ***************** This part enables the boot loader function ************/
#ifdef BOOT
/* Blink to indicate FOC selection */
volatile uint32_t myDelay;
volatile uint32_t cycle;
for (cycle = 0; cycle < 8; cycle++)
{
GPIOB->ODR ^= GPIO_PIN_2;
for (myDelay = 0; myDelay < 1000000; myDelay++);
}
#endif
/*! *************************************************************************/
/* USER CODE END 3 */
/* Infinite loop */
while (1)
{
}
/* USER CODE END 3 */
} |