Posted on Leave a comment

STM32F103C8T6 Blue Pill

The STM32F103C8T6 development board which is also known as Blue Pill is a small and affordable development board. It is based on the ARM Cortex-M3 processor and features 64KB of flash memory, 20KB of SRAM, and a maximum clock speed of 72MHz. The Blue Pill is a popular choice for hobbyists and developers who want to experiment with embedded systems and microcontrollers. In this blog post, we will take a closer look at the Blue Pill’s schematic diagram and pinout.

Documents

STM32F103C8 Product Page
Datasheet

How to program the stm32f103c8t6?

Step 1: Setting up the development environment

To program the Blue Pill, you will need a development environment that includes the necessary tools and software. A popular choice is the STM32CubeIDE, which is an integrated development environment (IDE) that includes a compiler, debugger, and other tools. You will also need to download the STM32F1xx HAL library, which provides a set of functions for configuring and controlling the microcontroller.

what are the other IDE which can be used to program stm32f103c8t6?

  • Keil MDK: Keil MDK is an integrated development environment (IDE) that supports the ARM Cortex-M processor family, including the STM32F103C8T6. It includes a compiler, linker, debugger, and other tools for developing embedded applications.
  • Eclipse IDE: Eclipse is a popular open-source IDE that supports a wide range of programming languages and platforms, including the STM32F103C8T6. Eclipse provides a plugin called “GNU ARM Eclipse” that includes tools for building and debugging ARM-based projects.
  • Visual Studio Code: Visual Studio Code is a popular open-source code editor that supports a wide range of programming languages and platforms, including the STM32F103C8T6. You can use Visual Studio Code with extensions to provide support for C/C++ development, debugging, and uploading code to the board.

Can IAR Embedded Workbench be used to program?

Yes, IAR Embedded Workbench is another popular IDE that can be used to program the STM32F103C8T6. IAR provides a comprehensive toolchain that includes a C/C++ compiler, linker, and debugger, as well as tools for code analysis and optimization.

Step 2: Configuring the microcontroller

Before writing code for the Blue Pill, you need to configure the microcontroller’s peripherals and registers. This involves setting up clock and power management, GPIO pins, timers, interrupts, and other peripherals, depending on your project’s requirements. The STM32F1xx HAL library provides functions for configuring the microcontroller, which you can use in your code.

Step 3: Writing and compiling the code

Once the microcontroller is configured, you can write your code using a programming language such as C or C++. You can use the STM32F1xx HAL library functions to interact with the microcontroller’s peripherals and registers. Once you have written your code, you need to compile it using the compiler included in your development environment.

Step 4: Uploading the code to the board

Once you have compiled your code, you need to upload it to the Blue Pill board. This involves connecting the board to your computer using a USB cable and using a programming tool such as ST-Link or J-Link to upload the code. You can use the programming tool’s software or your development environment’s built-in upload tool to upload the code.

Schematic Diagram:

The STM32F103C8T6 Blue Pill’s schematic diagram is relatively simple and straightforward. The board features a 3.3V voltage regulator, which is used to provide power to the microcontroller and other components. The board also includes an external crystal oscillator (HSE) and a 32.768 kHz crystal oscillator (LSE) for real-time clock (RTC) functionality.

Other key components on the board include:

Reset circuitry: The Blue Pill features a reset button and an external reset circuit to ensure the reliable and safe operation of the microcontroller.
USB connector: The board includes a USB connector that can be used for programming and communication with the microcontroller.
LED indicators: There are two LED indicators on the board, one for power and one for user-defined purposes.

Pinout:

The STM32F103C8T6 Blue Pill’s pinout is organized into four rows of headers, with a total of 20 pins. Here is a brief overview of the pin functions:

  • PA0 to PA15: These pins are general-purpose input/output (GPIO) pins that can be used for a variety of purposes, including digital input/output and analog input.
  • PB0 to PB15: These pins are also GPIO pins, with the same capabilities as the PA pins.
  • PC13 to PC15: These pins are typically used for the onboard LED indicators, but can also be used as GPIO pins.
  • VDD: This is the 3.3V power supply pin.
  • VSS: This is the ground pin.
  • BOOT0: This pin is used to select between the bootloader and the user code during programming.
  • NRST: This is the reset pin.
  • SWDIO and SWCLK: These pins are used for programming and debugging the microcontroller using the Serial Wire Debug (SWD) protocol.

The STM32F103C8T6 Blue Pill is a versatile and affordable development board that is well-suited for a wide range of projects. Its simple schematic diagram and clear pinout make it easy to work with, even for beginners. With its powerful ARM Cortex-M3 processor, ample memory, and rich set of peripherals, the Blue Pill is a great choice for anyone looking to dive into the world of microcontroller programming.

Posted on Leave a comment

Convert mA to A

Enter milli Ampere (mA):
Ampere (A)=

Definition

Ampere = One coulomb of charge going through per second

Milliampere = one-thousandth of an ampere

Formula

mA = A / 1000

Where:
mA = milliampere
A = Ampere

Example

Question: How to convert 800mA to A?
Answer:
800 x 10-3 = 800 milliampere
800 / 1000 = 0.8A

deutsche Sprache

Frage: Wie rechnet man 800 Milliampere in Ampere um?
Antwort:
800 x 10-3 = 800 milliampere
800 / 1000 = 0.8A

Posted on Leave a comment

BD139 Pinout

The BD139 is a general-purpose NPN bipolar junction transistor (BJT). It has three pins:

  1. Base (B)
  2. Collector (C)
  3. Emitter (E)

There are two companies that manufacture the transistor

  1. STMicroelectronics
  2. onsemi

The pinout diagram according to STMicroelectronics is as follows:

When looking at the center hole and keeping the metal side down the pins are arranged from right to left as:

  1. Base (B)
  2. Collector (C)
  3. Emitter (E)

It’s important to note that the metal tab is connected to the Collector pin.

The pinout diagram according to ON Semiconductor is as follows:

When looking at the flat side of the transistor with the pins facing down and the metal tab facing up, the pins are arranged from left to right as follows:

  1. Emitter (E)
  2. Collector (C)
  3. Base (B)

It’s important to note that the metal tab is connected to the Collector pin.

Posted on Leave a comment

Raspberry Pi Pico W

Raspberry Pi Pico W Datasheet
Connecting to the Internet with Raspberry Pi Pico W
RP2040 Datasheet

NOTE: The CYW43439 supports both 802.11 wireless and Bluetooth, initially Pico W does not have Bluetooth support. Support may be added later, and will use the same SPI interface. If support is added existing hardware may require a firmware update to support Bluetooth, but there will be no hardware modifications needed.

Technical Specification
  • RP2040 microcontroller with 2MB of flash memory
  • On-board single-band 2.4GHz wireless interfaces (802.11n)
  • Micro USB B port for power and data (and for reprogramming the flash)
  • 40-pin 21mm×51mm ‘DIP’ style 1mm thick PCB with 0.1″ through-hole pins also with edge castellations
    • Exposes 26 multi-function 3.3V general purpose I/O (GPIO)
    • 23 GPIO are digital-only, with three also being ADC capable
    • Can be surface-mounted as a module
  • 3-pin Arm serial wire debug (SWD) port
  • Simple yet highly flexible power supply architecture
    • Various options for easily powering the unit from micro USB, external supplies or batteries
  • High quality, low cost, high availability
  • Comprehensive SDK, software examples and documentation
  • Dual-core cortex M0+ at up to 133MHz
  • 264kB multi-bank high performance SRAM
  • External Quad-SPI flash with eXecute In Place (XIP) and 16kB on-chip cache
  • High performance full-crossbar bus fabric
  • On-board USB1.1 (device or host)
  • 30 multi-function general purpose I/O (four can be used for ADC)
    • 1.8-3.3V I/O voltage
  • 12-bit 500ksps analogue to digital converter (ADC)
  • Various digital peripherals
    • 2 × UART, 2 × I2C, 2 × SPI, 16 × PWM channels
    • 1 × timer with 4 alarms, 1 × real time clock
  • 2 × programmable I/O (PIO) blocks, 8 state machines in total
    • Flexible, user-programmable high-speed I/O
    • Can emulate interfaces such as SD card and VGA

Schematic Diagram

Raspberry Pi Pico W Schematic 2
Raspberry Pi Pico W Schematic component Location
Raspberry Pi Pico W Schematic 1

Raspberry Pi Pico W Pinout

Posted on Leave a comment

German Language vlog 14 – Clues for Masculine Nouns

Male Person

der Großvater		-	Grandfather 
der Onkel		-	Uncle 
der Vater		-	Father	 
der Cousin		-	Cousin 
der Bruder		-	Brother 
der Sohn		-	Son 
der Ehemann		-	Husband 
der Schwiegervater	-	father-in-law 
der Schwiegersohn	-	son in law 
der Schwager		-	brother in law 
der Neffe		-	Nephew 
der Enkel		-	Grandson 
der Mann		-	Man 
der Erwachsene		-	Adult 
der Junge		-	Boy 
der Stiefvater		-	Stepfather 
der Stiefsohn		-	Stepson 
der Partner		-	Partner 

Weekdays – Wochentage

Monday		-	der Montag	
Tuesday		-	der Dienstag	
Wednesday	-	der Mittwoch	
Thursday	-	der Donnerstag	
Friday		-	der Freitag	
Saturday	-	der Samstag
Sunday		-	der Sonntag

German Seasons – Deutsche Jahreszeiten

der Winter	-	winter
der Frühling	-	spring
der Sommer	-	Summer
der Herbest	-	Autumn

Makes of Cars
der BMW – BMW
der Jaguar – Jaguar

Alcoholic Drinks
der Whisky – Whisky
der Wien – Wine

‘Beer’ is an exception and neuter = das Beer

Posted on Leave a comment

German Language vlog 13 – Nouns and Gender

German Nouns have grammatical gender and not biological gender. What this means is that sometimes a person can be of different gender even if it biological gender is actually something else.

example: A young girl is biologically female. So her gender would be feminine.
But in german it is das Mädchen. Here das indicates neuter gender, which comes from the grammatical gender.

So it is always best to learn a noun with its article and gender. It will help in the long term.

The article change depending on the use of the noun in Accusative, Nominative, Dative, or Genative.

The article ‘the’ will always be ‘die’ for all the plural nouns.

Posted on Leave a comment

Merge Sort is bad for Embedded System

Merge sort is good if your system has plenty of memory to accommodate the temporary array.

Embedded systems have very limited memory and it is often fixed.

If the system has some other function that also runs concurrently. Then that memory also gets shortened.

Merge sort is good for a bigger system like the personal computer and business computer which have the bigger memory in which all the temporary array can reside.

The advantage of merge sort is that it is stable.

Since it takes a lot of space it is not useful for an embedded system, as they have a very small memory sometimes it is just KilloByte.
example:
ATmega328p = 2KB SRAM
ATtiny85 = 512B SRAM

Code for STM32F429ZIT6

This code redirects the printf statements towards the asynchronous UART.
As the size of input array for merge sort increases the space required to store temporary element increases, which eventually leads to stalling of the program.
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
#include "stdlib.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/*
* Function Name: _write
* Function Description: Redirect the printf() statement towards the UART using the HAL_UART_Transmit
Author: Abhay

*/
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
 //   HAL_UART_Transmit(&huart1, ptr, len, Timeout)
    return len;
}

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
	int i, j, k;
	int n1 = m - l + 1;
	int n2 = r - m;

	/* create temp arrays */
	int L[n1], R[n2];

	/* Copy data to temp arrays L[] and R[] */
	for (i = 0; i < n1; i++)
		L[i] = arr[l + i];
	for (j = 0; j < n2; j++)
		R[j] = arr[m + 1 + j];

	/* Merge the temp arrays back into arr[l..r]*/
	i = 0; // Initial index of first subarray
	j = 0; // Initial index of second subarray
	k = l; // Initial index of merged subarray
	while (i < n1 && j < n2) {
		if (L[i] <= R[j]) {
			arr[k] = L[i];
			i++;
		}
		else {
			arr[k] = R[j];
			j++;
		}
		k++;
	}

	/* Copy the remaining elements of L[], if there
	are any */
	while (i < n1) {
		arr[k] = L[i];
		i++;
		k++;
	}

	/* Copy the remaining elements of R[], if there
	are any */
	while (j < n2) {
		arr[k] = R[j];
		j++;
		k++;
	}
}

/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
	if (l < r) {
		// Same as (l+r)/2, but avoids overflow for
		// large l and h
		int m = l + (r - l) / 2;

		// Sort first and second halves
		mergeSort(arr, l, m);
		mergeSort(arr, m + 1, r);

		merge(arr, l, m, r);
	}
}

/* UTILITY FUNCTIONS */
/* Function to print an array */
void printArray(int A[], int size)
{
	int i;
	for (i = 0; i < size; i++)
		printf("%d ", A[i]);
	printf("\n");
}

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
  int arr[] = { 12, 11, 13, 5, 6, 7,12};
        int arr_size = sizeof(arr) / sizeof(arr[0]);

//        for( int temp=0; temp<1023;temp++){
//  	arr[temp] = rand()*1000;
//  }
        printf("Given array is \n");
        printArray(arr, arr_size);

        mergeSort(arr, 0, arr_size - 1);

        printf("\nSorted array is \n");
        printArray(arr, arr_size);
     //   return 0;
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

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

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  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;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** 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.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  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)
  {
    Error_Handler();
  }
}

/**
  * @brief USART1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOG_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOG, ledg_Pin|ledr_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pins : ledg_Pin ledr_Pin */
  GPIO_InitStruct.Pin = ledg_Pin|ledr_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @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 CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
Posted on Leave a comment

German Language vlog 12 – Questions

Question WordsExamples
Wer?
Why?
Frage 1: Wer bist du?
Antwort: Ich bin Abhay.

Frage 2: Wer sind Sie?
Antwort: Ich hieße Parker.
Was?
What?
Frage 1: Was machst du?
Antwort: Ich lese ein Buch. (I am reading a Book.)
Wo?
Where?
Frage 1: Wo ist Einstein?
Antwort 1: Er ist im kindergarten.(He is in the Kindergarten)
Antwort 2: Er ist in der Schule. (He is at the school.)
Woher?
Where … from?
Frage 1: woher kommen sie?
Antwort: Ich komme aus New Delhi.
Wohin?
Where … to?
Frage 1: Wohin gehst du?
Antwort: Zum Frisör
Wann?
When?
Wann treffen wir uns? – When do we meet?
Wann geht der Flug? – When does the plane leave?
Wann beginnt das Konzert? – When does the concert start?
Wann hast du Geburtstag? – When is your birthday? [informal]
Warum?
Why?
Frage: Warum ist der Sonne gelb?
Wie?
How?
Frage: Wie alt bist du?
Antwort: Ich bin neun jahre alt.
Wie viel?
How much?
Frage: Wie viel kostet die wurst?
Wie viele?
How many?
Frage: wie viele finger sind in einer hand?
Wie oft?
How often?
Frage: Wie oft spielst du?
Posted on Leave a comment

German Language vlog 11 – Ordinal Numbers

Ordinal Numbers are called ‘Ordnungszahlen’ in German.

Ordinal Numbers are first, second, third, and so on in English.

In german, there are few rules to make them. But they are easy to understand and once you get to practice you can easily understand them.

Note: The spelling of ‘1’ and ‘3’ are different as they are irregular.

Beispiel

Fünfte
Fifth

Frage: Was ist zehnte in Englisch Ziffer?
Antwort:
Zehnte gleich Tenth in Englisch.