cancel
Showing results for 
Search instead for 
Did you mean: 

debugging a hoverboard motor controller

iamrobot
Visitor

i have a hoverboard motor controller in which there is STM32F103RCT6.
i have hacked the firmware but it was not working due to some reason; some MOSFET got burned.
i tried to check communication with Arduino.

 

 
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
*/
/* USER CODE END Header */

#include "main.h"

/* USER CODE BEGIN Includes */
#include <string.h>
/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart3;

/* USER CODE BEGIN PV */
char msg[] = "STM32 UART TEST\r\n";
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART3_UART_Init(void);

int main(void)
{
HAL_Init();

SystemClock_Config();

MX_GPIO_Init();
MX_USART3_UART_Init();

/* USER CODE BEGIN 2 */
HAL_UART_Transmit(&huart3, (uint8_t*)msg, strlen(msg), 100);
/* USER CODE END 2 */

while (1)
{
/* USER CODE BEGIN 3 */
HAL_UART_Transmit(&huart3, (uint8_t*)msg, strlen(msg), 100);
HAL_Delay(500);
/* USER CODE END 3 */
}
}

/* Clock config (unchanged CubeMX generated) */
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
}

/* USART3 Init (PB10 TX, PB11 RX) */
static void MX_USART3_UART_Init(void)
{
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;

HAL_UART_Init(&huart3);
}

/* GPIO Init */
static void MX_GPIO_Init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
}

/* Error handler */
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}

when I flash it, my STM is not being detected by ST-Link. I am trying to check whether the issue is with the STM or the firmware. I also flashed it into another board, but the same issue happened, so I guess the problem is in the firmware.

the power is good; I checked between all VDD and VSS and it is good (3.27V).
there is BOOT0, BOOT1, and NRST.
BOOT0 and BOOT1 are low and NRST is high.
when I short BOOT0 with VDD, the ST-Link turns off.

I am completely lost.

the screen shot is after and before firmware 

2 REPLIES 2
Andrew Neil
Super User

welcome to the forum

Please see How to write your question to maximize your chances to find a solution for best results.

 


@iamrobot wrote:

i have a hoverboard motor controller in which there is STM32F103RCT6.


Please give full details - is this your own design? a commercial design?

Note that STM32F103RCT6 are widely faked/cloned - are you sure you have a genuine one?

 


@iamrobot wrote:

when I flash it, my STM is not being detected by ST-Link.  


What ST-Link are you using?

Again, there are many clones: How to recognize a genuine ST-LINK/V2 versus a cloned one

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
iamrobot
Visitor

thanks

mainboard_pinout.png

l am using this board (hoverboard contoller) it was working before the problem is i flashed the firmware which by some reason made the stm not loading by stlink 
how can i completely reset the chip so the stlink debugger can work i have now working code
attached the schematic i found online