trying to write a blink sketch for STM32F4 discovery board

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

Posts: 1
Joined: Mon Jan 07, 2019 5:21 pm

trying to write a blink sketch for STM32F4 discovery board

Postby vixo » Mon Jul 08, 2019 2:01 pm

Hi, I'm trying to write a simple blink sketch using an STM32F4(07) discovery board, CubeMX and Atollic truestudio. I can't find any walkthrough guides which cover this exact constellation of products, so I'm trying to mix and match and I can't get my code to build properly.

I used the cubeMX program to select pd12-15 as GPIO output and then the debug in sys mode to debug wire (i'm assuming this is appropriate for my discovery board?). The clock configuration seems to be set so I can't alter it (I'm guessing because i've chosen the discovery board which has default settings?) I don't know what to do with the tools section, I just left it blank. I select truestudio in the toolchain/IDE section and open the project.

This creates a project with a lot of stuff that I have no idea about contained within it. it is much more complicated than the code snippet recommended in this tutorial - http://embeddedsystemengineering.blogsp ... e-led.html which is very simple and easy to understand. Instead I get this -

Code: Select all

#include "main.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
int main(void)
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  /* Configure the system clock */
  /* Initialize all configured peripherals */
  while (1)
void SystemClock_Config(void)
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  /** Configure the main internal regulator output voltage
  /** Initializes the CPU, AHB and APB busses clocks
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  /** Initializes the CPU, AHB and APB busses clocks
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
static void MX_GPIO_Init(void)
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  /* GPIO Ports Clock Enable */
  /*Configure GPIO pin Output Level */
  /*Configure GPIO pins : PD12 PD13 PD14 PD15 */
  GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
void Error_Handler(void)
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  /* USER CODE END Error_Handler_Debug */
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
void assert_failed(uint8_t *file, uint32_t line)
  /* User can add his own implementation to report the file name and line number,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
#endif /* USE_FULL_ASSERT */

Which i almost understand, but I don't know how the code in the other example built for the same discovery board (although with a different IDE) can be so simple in comparison. Nevertheless, this code does not compile - trueStudio says "fatal error: arm_math.h: no such file or directory" Which I don't understand because a) i don't know why I need math.h (it's not called anywhere in the program) and b) if I follow the dropdown boxes in the left bar I can go in to drivers>CMSIS>DSP>source>BasicMathFunctions> arm_shift_q15.c and math.h is listed under there, all of these foldeers are highlighted by a red 'x' in a box, but the compiler can't seem to find the file which I can see following those links??

I also tried to paste the code from the simpler example (from the link above) but this also creates an error.

can anyone help me out?

Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: No registered users and 2 guests