rs485 not working as expected

stable
Penguin 3 years ago
parent 6988019971
commit 4751793db5

@ -55,6 +55,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
/* USER CODE BEGIN EFP */

@ -52,11 +52,10 @@ UART_HandleTypeDef huart2;
/* USER CODE BEGIN PV */
volatile uint8_t huart2_rxc;
volatile uint8_t huart1_rxc;
static volatile uint32_t sys_time = 0;
static volatile bool b_timer_struck = false;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@ -121,6 +120,8 @@ int main(void)
mc_init(&htim2);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
HAL_TIM_Base_Start_IT(&htim6);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
uint16_t motor_degrees = 0;
/* USER CODE END 2 */
@ -185,8 +186,7 @@ void SystemClock_Config(void)
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
@ -253,7 +253,6 @@ static void MX_TIM2_Init(void)
/* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit(&htim2);
}
/**
@ -291,7 +290,6 @@ static void MX_TIM6_Init(void)
/* USER CODE BEGIN TIM6_Init 2 */
/* USER CODE END TIM6_Init 2 */
}
/**
@ -326,7 +324,6 @@ static void MX_USART1_UART_Init(void)
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
/**
@ -361,7 +358,6 @@ static void MX_USART2_UART_Init(void)
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}
/**
@ -387,15 +383,22 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart == &huart1)
{
HAL_UART_Transmit(&huart2, &huart1_rxc, 1, 100);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
}
else if (huart == &huart2)
{
HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 100);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{

@ -240,6 +240,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USART1 interrupt Init */
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE END USART1_MspInit 1 */
@ -314,6 +317,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7);
/* USART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */

@ -56,6 +56,7 @@
/* External variables --------------------------------------------------------*/
extern TIM_HandleTypeDef htim6;
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN EV */
@ -199,6 +200,20 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32l4xx.s). */
/******************************************************************************/
/**
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
/**
* @brief This function handles USART2 global interrupt.
*/

@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Wed Apr 06 17:40:48 CDT 2022]
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Thu Apr 07 18:39:18 CDT 2022]
##########################################################################################################################
# ------------------------------------------------

@ -25,14 +25,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-o",
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/stm32l4xx_it.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
},
{
"arguments": [
@ -60,14 +60,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_gpio.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_gpio.lst",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-o",
"build/stm32l4xx_hal_gpio.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
},
{
"arguments": [
@ -95,14 +95,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-o",
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
},
{
"arguments": [
@ -130,14 +130,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-o",
"build/motor_controller.o",
"shared/devices/motor_controller.c"
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "shared/devices/motor_controller.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
},
{
"arguments": [
@ -165,14 +165,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-o",
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/stm32l4xx_hal_msp.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
},
{
"arguments": [
@ -200,14 +200,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-o",
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
},
{
"arguments": [
@ -235,14 +235,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-o",
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/system_stm32l4xx.c"
},
{
"arguments": [
@ -270,14 +270,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-o",
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
},
{
"arguments": [
@ -305,21 +305,19 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-o",
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-x",
"assembler-with-cpp",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
@ -342,13 +340,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/startup_stm32l432xx.d",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-o",
"build/startup_stm32l432xx.o",
"startup_stm32l432xx.s"
"build/main.o",
"Core/Src/main.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "startup_stm32l432xx.s"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/main.c"
},
{
"arguments": [
@ -376,14 +375,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-o",
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"build/putil.o",
"shared/util/putil.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/util/putil.c"
},
{
"arguments": [
@ -411,14 +410,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-o",
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
},
{
"arguments": [
@ -452,7 +451,7 @@
"build/stm32l4xx_hal_rcc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c"
},
{
@ -481,14 +480,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-o",
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_hal_msp.c"
},
{
"arguments": [
@ -516,14 +515,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-o",
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
},
{
"arguments": [
@ -551,14 +550,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-o",
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
},
{
"arguments": [
@ -586,14 +585,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-o",
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
},
{
"arguments": [
@ -621,14 +620,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-o",
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_it.c"
},
{
"arguments": [
@ -656,14 +655,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_exti.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_exti.lst",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-o",
"build/stm32l4xx_hal_exti.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
"build/motor_controller.o",
"shared/devices/motor_controller.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/devices/motor_controller.c"
},
{
"arguments": [
@ -691,14 +690,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-MFbuild/stm32l4xx_hal_exti.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_exti.lst",
"-o",
"build/putil.o",
"shared/util/putil.c"
"build/stm32l4xx_hal_exti.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "shared/util/putil.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c"
},
{
"arguments": [
@ -726,19 +725,21 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-o",
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-x",
"assembler-with-cpp",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
@ -761,14 +762,13 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-MFbuild/startup_stm32l432xx.d",
"-o",
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"build/startup_stm32l432xx.o",
"startup_stm32l432xx.s"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "startup_stm32l432xx.s"
},
{
"arguments": [
@ -796,14 +796,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-o",
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
},
{
"arguments": [
@ -831,14 +831,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-o",
"build/main.o",
"Core/Src/main.c"
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/main.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
},
{
"arguments": [
@ -866,14 +866,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-MFbuild/stm32l4xx_hal_gpio.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_gpio.lst",
"-o",
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
"build/stm32l4xx_hal_gpio.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Core/Src/system_stm32l4xx.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
},
{
"arguments": [
@ -901,13 +901,13 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-o",
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
],
"directory": "/storage/Shared/Projects/stm32_projects/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
}
]

@ -5993,3 +5993,205 @@ A debugging session is active.
Quit anyway? (y or n) [answered Y; input not from terminal]
[Inferior 1 (Remote target) detached]
0x08001578 in main () at Core/Src/main.c:110
110 p_uart_init(&huart2);
### Assembly ###############################################################################################################################################################################################################################
0x0800156a main+18 mov r0, r5
0x0800156c main+20 bl 0x8003e98 <HAL_UART_Init+90>
0x08001570 main+24 ldr r0, [pc, #68] ; (0x80015b8 <main+96>)
0x08001572 main+26 bl 0x8001990 <TIM_OC4_SetConfig+48>
0x08001576 main+30 movs r4, #0
0x08001578 main+32 ldr r3, [pc, #64] ; (0x80015bc <main+100>)
0x0800157a main+34 ldrb r3, [r3, #0]
0x0800157c main+36 cmp r3, #0
0x0800157e main+38 beq.n 0x8001578 <main+32>
0x08001580 main+40 ldr r3, [pc, #56] ; (0x80015bc <main+100>)
### Breakpoints ############################################################################################################################################################################################################################
### Expressions ############################################################################################################################################################################################################################
### History ################################################################################################################################################################################################################################
### Memory #################################################################################################################################################################################################################################
### Registers ##############################################################################################################################################################################################################################
r0 0x00000000 r3 0x00000000 r6 0x00000000 r9 0x00000000 r12 0x00001000 pc 0x08001578 msp 0x2000fff0 basepri 0x00
r1 0x00000000 r4 0x0000012b r7 0x00000000 r10 0x00000000 sp 0x2000fff0 xPSR 0x61010000 psp 0x00000000 faultmask 0x00
r2 0x00000001 r5 0x20000a60 r8 0x00000000 r11 0x00000000 lr 0x08001f3d fpscr 0x20000010 primask 0x00 control 0x04
### Source #################################################################################################################################################################################################################################
100
101 /* USER CODE END SysInit */
102
103 /* Initialize all configured peripherals */
104 MX_GPIO_Init();
105 MX_TIM2_Init();
106 MX_USART2_UART_Init();
107 MX_TIM6_Init();
108 MX_USART1_UART_Init();
109 /* USER CODE BEGIN 2 */
110 p_uart_init(&huart2);
111
112 // HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
113 // HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
114 setPWM(&htim2, TIM_CHANNEL_2, 50);
115 setPWM(&htim2, TIM_CHANNEL_4, 25);
116
117 HAL_GPIO_WritePin(m1_dir_GPIO_Port, m1_dir_Pin, 1);
118 HAL_GPIO_WritePin(m2_dir_GPIO_Port, m2_dir_Pin, 1);
119
### Stack ##################################################################################################################################################################################################################################
[0] from 0x08001578 in main+32 at Core/Src/main.c:110
### Threads ################################################################################################################################################################################################################################
[1] id 0 from 0x08001578 in main+32 at Core/Src/main.c:110
### Variables ##############################################################################################################################################################################################################################
loc motor_degrees = <optimized out>
############################################################################################################################################################################################################################################
Loading section .isr_vector, size 0x190 lma 0x8000000
Loading section .text, size 0xa8e8 lma 0x80001c0
Loading section .rodata, size 0x688 lma 0x800aaa8
Loading section .ARM, size 0x8 lma 0x800b130
Loading section .init_array, size 0x8 lma 0x800b138
Loading section .fini_array, size 0x8 lma 0x800b140
Loading section .data, size 0x9a8 lma 0x800b148
Start address 0x080041c8, load size 47808
Transfer rate: 30 KB/sec, 5312 bytes/write.
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]
[Inferior 1 (Remote target) detached]
main () at Core/Src/main.c:132
132 if (b_timer_struck)
### Assembly ########################################################################################################
0x080015c2 main+106 movs r2, #1
0x080015c4 main+108 ldr r1, [pc, #72] ; (0x8001610 <main+184>)
0x080015c6 main+110 ldr r0, [pc, #76] ; (0x8001614 <main+188>)
0x080015c8 main+112 bl 0x8003f78 <HAL_UART_Receive_IT>
0x080015cc main+116 movs r4, #0
0x080015ce main+118 ldr r3, [pc, #72] ; (0x8001618 <main+192>)
0x080015d0 main+120 ldrb r3, [r3, #0]
0x080015d2 main+122 cmp r3, #0
0x080015d4 main+124 beq.n 0x80015ce <main+118>
0x080015d6 main+126 ldr r3, [pc, #64] ; (0x8001618 <main+192>)
### Breakpoints #####################################################################################################
### Expressions #####################################################################################################
### History #########################################################################################################
### Memory ##########################################################################################################
### Registers #######################################################################################################
r0 0x00000000 r5 0x20000ae8 r10 0x00000000 pc 0x080015ce primask 0x00
r1 0x00000000 r6 0x00000000 r11 0x00000000 xPSR 0x61010000 basepri 0x00
r2 0x00000001 r7 0x00000000 r12 0x00001000 fpscr 0x20000010 faultmask 0x00
r3 0x00000000 r8 0x00000000 sp 0x2000fff0 msp 0x2000fff0 control 0x04
r4 0x0000015a r9 0x00000000 lr 0x0800201d psp 0x00000000
### Source ##########################################################################################################
122 HAL_TIM_Base_Start_IT(&htim6);
123
124 HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
125 uint16_t motor_degrees = 0;
126 /* USER CODE END 2 */
127
128 /* Infinite loop */
129 /* USER CODE BEGIN WHILE */
130 while (1)
131 {
132 if (b_timer_struck)
133 {
134 // PDEBUG("%d\n", sys_time);
135 b_timer_struck = false;
136 motor_degrees = (motor_degrees + 1) % 360;
137 mc_service(motor_degrees, 50);
138 }
139 /* USER CODE END WHILE */
140
141 /* USER CODE BEGIN 3 */
### Stack ###########################################################################################################
[0] from 0x080015ce in main+118 at Core/Src/main.c:132
### Threads #########################################################################################################
[1] id 0 from 0x080015ce in main+118 at Core/Src/main.c:132
### Variables #######################################################################################################
loc motor_degrees = 346
#####################################################################################################################
Loading section .isr_vector, size 0x190 lma 0x8000000
Loading section .text, size 0xa8c0 lma 0x80001c0
Loading section .rodata, size 0x648 lma 0x800aa80
Loading section .ARM, size 0x8 lma 0x800b0c8
Loading section .init_array, size 0x8 lma 0x800b0d0
Loading section .fini_array, size 0x8 lma 0x800b0d8
Loading section .data, size 0x9a8 lma 0x800b0e0
Start address 0x080041a0, load size 47704
Transfer rate: 30 KB/sec, 5300 bytes/write.
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]
[Inferior 1 (Remote target) detached]
0x080015d0 in main () at Core/Src/main.c:132
132 if (b_timer_struck)
### Assembly ########################################################################################################
0x080015c4 main+108 ldr r1, [pc, #72] ; (0x8001610 <main+184>)
0x080015c6 main+110 ldr r0, [pc, #76] ; (0x8001614 <main+188>)
0x080015c8 main+112 bl 0x8003f78 <HAL_UART_Receive_IT>
0x080015cc main+116 movs r4, #0
0x080015ce main+118 ldr r3, [pc, #72] ; (0x8001618 <main+192>)
0x080015d0 main+120 ldrb r3, [r3, #0]
0x080015d2 main+122 cmp r3, #0
0x080015d4 main+124 beq.n 0x80015ce <main+118>
0x080015d6 main+126 ldr r3, [pc, #64] ; (0x8001618 <main+192>)
0x080015d8 main+128 movs r2, #0
### Breakpoints #####################################################################################################
### Expressions #####################################################################################################
### History #########################################################################################################
### Memory ##########################################################################################################
### Registers #######################################################################################################
r0 0x00000000 r5 0x20000ae8 r10 0x00000000 pc 0x080015d0 primask 0x00
r1 0x00000000 r6 0x00000000 r11 0x00000000 xPSR 0x61000000 basepri 0x00
r2 0x00000001 r7 0x00000000 r12 0x00001000 fpscr 0x80000010 faultmask 0x00
r3 0x200009c4 r8 0x00000000 sp 0x2000fff0 msp 0x2000fff0 control 0x04
r4 0x00000068 r9 0x00000000 lr 0x0800201d psp 0x00000000
### Source ##########################################################################################################
122 HAL_TIM_Base_Start_IT(&htim6);
123
124 HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
125 uint16_t motor_degrees = 0;
126 /* USER CODE END 2 */
127
128 /* Infinite loop */
129 /* USER CODE BEGIN WHILE */
130 while (1)
131 {
132 if (b_timer_struck)
133 {
134 // PDEBUG("%d\n", sys_time);
135 b_timer_struck = false;
136 motor_degrees = (motor_degrees + 1) % 360;
137 mc_service(motor_degrees, 50);
138 }
139 /* USER CODE END WHILE */
140
141 /* USER CODE BEGIN 3 */
### Stack ###########################################################################################################
[0] from 0x080015d0 in main+120 at Core/Src/main.c:132
### Threads #########################################################################################################
[1] id 0 from 0x080015d0 in main+120 at Core/Src/main.c:132
### Variables #######################################################################################################
loc motor_degrees = 104
#####################################################################################################################
Loading section .isr_vector, size 0x190 lma 0x8000000
Loading section .text, size 0xa8c0 lma 0x80001c0
Loading section .rodata, size 0x648 lma 0x800aa80
Loading section .ARM, size 0x8 lma 0x800b0c8
Loading section .init_array, size 0x8 lma 0x800b0d0
Loading section .fini_array, size 0x8 lma 0x800b0d8
Loading section .data, size 0x9a8 lma 0x800b0e0
Start address 0x080041a0, load size 47704
Transfer rate: 30 KB/sec, 5300 bytes/write.
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]
[Inferior 1 (Remote target) detached]

@ -46,6 +46,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
PA0.GPIOParameters=GPIO_Label

@ -1,7 +1,7 @@
#include "motor_controller.h"
#include <math.h>
#include "putil.h"
#include "stm32l4xx_hal_tim.h"
#include <math.h>
static TIM_HandleTypeDef *_motor_timer = NULL;
void mc_init(TIM_HandleTypeDef *tim)
@ -15,11 +15,11 @@ void mc_service(uint16_t degrees, uint8_t speed)
{
float right_pwm = cos(((float)degrees * (3.1415 / 180.0f)));
float left_pwm = right_pwm;
PDEBUG("| DEGREES | COS | SIN | \n");
PDEBUG("| %7d | %-5.3f | %-5.3f | \n",
(int)degrees,
right_pwm,
right_pwm);
// PDEBUG("| DEGREES | COS | SIN | \n");
// PDEBUG("| %7d | %-5.3f | %-5.3f | \n",
// (int)degrees,
// right_pwm,
// right_pwm);
HAL_GPIO_WritePin(m1_dir_GPIO_Port, m1_dir_Pin, right_pwm >= 0 ? 0 : 1);
HAL_GPIO_WritePin(m2_dir_GPIO_Port, m2_dir_Pin, left_pwm >= 0 ? 0 : 1);

Loading…
Cancel
Save