Docs

Micro-controllers, wireless transmission and database

Head

Blue Pill SWV with Cube Programmer using STM32CubeIDE

Prerequisites

This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with blue-pill using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A

Wiring Diagram

Diagram

Additional code on top of STM32CubeIDE generated code

/* USER CODE BEGIN Includes */
#include "stdio.h"
/* USER CODE END Includes */

/* USER CODE BEGIN 0 */
int myNum = 2024; // Integer (whole number)
float myFloatNum = 5.98; // Floating point number
char myLetter = 'D';
uint8_t myUint = 21; // Same way for uint16_t or uint32_t
uint8_t myArray[20] = {0};
int _write(int file, char *ptr, int len)
{
  int DataIdx;
  for (DataIdx = 0; DataIdx < len; DataIdx++)
  {
    ITM_SendChar(*ptr++);
  }
  return len;
}
/* USER CODE END 0 */

/* USER CODE BEGIN WHILE */
while (1)
{
  printf("While reached\n");
  printf("Number %d\n",myNum );
  printf("#GRN#Float %f\n",myFloatNum );
  printf("#RED#Letter %c\n",myLetter );
  printf("#ORG#uint8_t %d\n",myUint );
  myArray[5]=7;
  printf("Array %d\n\n",myArray[5] );
  myNum++;
  HAL_Delay(1000);
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */