💾
EC
  • Introduction
  • EC Course
    • Syllabus
    • Preparation for EC
    • Tutorial
      • Tutorial: arduino-stm32
        • Tutorial: arduino-stm32 Installation
        • Tutorial: arduino-stm32 Part1
        • Tutorial: arduino-stm32 Part2
      • Tutorial: MDK uVision
        • Tutorial: Installing MDK uVision
        • Tutorial: Create a Project with uVision
        • Tutorial: Adding library header in uVision
        • Tutorial: Re-using Project Configuration
        • Debugging in uVision
      • Tutorial: PlatformIO in CLion
      • Tutorial: PlatformIO in VSCode
      • Tutorial: Repository Management
      • Tutorial: Managing library header files
      • Tutorial: PinName Configuration
      • Tutorial: Bitwise Macro
      • Tutorial: Custom initialization
      • Tutorial: Documentation
      • Tutorial: Creating Application API
      • Tutorial: 7-Segment Display
      • Tutorial: DC motor driver connection
      • Tutorial: USART with TeraTerm
      • Tutorial: Finite State Machine programming
      • Tutorial: Bluetooth
      • Tutorial: Zigbee with Nucleo board
    • LAB
      • LAB Report Template
      • LAB: Smart mini-fan with STM32-duino
      • LAB: Portable Fan with mbed
      • LAB: GPIO Digital InOut
      • LAB: GPIO Digital InOut 7-segment
      • LAB: EXTI & SysTick
      • LAB: Timer & PWM
      • LAB: Stepper Motor
      • LAB: Input Capture - Ultrasonic
      • LAB: USART - LED, Bluetooth
      • LAB: ADC - IR reflective sensor
      • LAB: Line Tracing RC Car
    • Sample code
      • Code Templates
    • Hardware
      • Nucleo-F411RE
      • LAB Hardware
        • Electronic Chips
        • HUINS Embedded Kit
    • Projects
      • Line Tracing Car Project
      • Design Project
        • Past Projects
      • Project Grading Criteria
    • Study Resource for MCU
      • Hexa-Decimal Table
      • Bitwise Op for Register
      • System Clock
      • Timer
      • USART
      • ADC
  • STM32 M4 Programming
    • Documentation
      • C++ API Docs
    • Firmware Library
      • PinName Configuration
      • GPIO Digital
      • RCC
      • EXTI_SysTick
      • TIMER
      • USART
    • Troubleshooting
    • mbed for STM32
      • Tutorial: mbed-Part 1
      • Tutorial: mbed - Part 2
      • Tutorial: mbed - Part 3
      • Using mbed API on uVision
    • mbed OS
  • Other Programming
    • Arduino
    • Socket Programming
      • Window Socket Programming
      • Arduino WiFi
    • Cube-MX
    • Github
    • Markdown
      • Example: API documentation
    • MATLAB
  • C Programming
    • C-Programming Lessons
      • Installing Visual Studio Community
        • Visual Studio Community 2022
      • Installing VS Code(Mac/Linux)
      • Creating Header Lib
      • Pointer
      • Array
      • 2D Array
      • Structure
      • Dynamic Alloc
      • Bitwise Operation
  • Numerical Programming
    • Syllabus
    • Preparation for NP
    • Math Review
    • Tutorial
      • TA Session Video
      • Tutorial: NP Library Header Files
      • Tutorial - Sine Taylor
      • Tutorial: Passing a Function, Function callback
      • Tutorial: Nonlinear solver
      • Tutorial: Differentiation
      • Tutorial: Integration
      • Tutorial: Matrix Structure
      • Tutorial: Eigenvalue problem
      • Tutorial: ODE-IVP
      • Tutorial: Curve Fitting
      • Tutorial: Create Github Repos of NP lib
      • Tutorial: Version Control in Github
      • Tutorial: Documentation with Markdown
      • Exercise: Version Control and Documentation
    • Example: MATLAB
    • Example: NP Library
    • Assignment
      • Assignment Factorial and Power
      • Assignment: Version Control and Documentation
    • Problem Bank
Powered by GitBook
On this page
  • Tutorial: Adding library header in uVision
  • Preparation
  • Include Library Path
  • 3. Specify 'Include Path' for your Include

Was this helpful?

  1. EC Course
  2. Tutorial
  3. Tutorial: MDK uVision

Tutorial: Adding library header in uVision

PreviousTutorial: Create a Project with uVisionNextTutorial: Re-using Project Configuration

Last updated 8 months ago

Was this helpful?

Tutorial: Adding library header in uVision

This tutorial explains how to include header files in uVision project.

Preparation

1. Download header files

Here, we assume that necessary header files are stored in your workspace ..\..\repos\EC\include\

Download tutorial source files

  • :

    • ,

    • ,

Include header files, located in a specific folder

  • save the downloaded header files in your workspace: ..\..\repos\EC\include\

image

2. Create a New Project in uVision

You can skip this if you already have the project opened.

3. Create a new source main file.

We will modify the main program code as

#include "ecSTM32_simple.h"


#define LED_PIN PA_5
#define BUTTON_PIN PC_13

void setup(void);

int main(void) { 
 	setup();
	int buttonState=0;
	
	while(1){
		// check if the pushbutton is pressed. Turn LED on/off accordingly:
		buttonState = 	GPIO_read(BUTTON_PIN);
		if(buttonState)	GPIO_write(LED_PIN, LOW);
		else 		GPIO_write(LED_PIN, HIGH);
	}
}


// Initialiization 
void setup(void) {
	RCC_HSI_init();
	// initialize the pushbutton pin as an input:
	GPIO_init(BUTTON_PIN, INPUT);  
	// initialize the LED pin as an output:
	GPIO_init(LED_PIN, OUTPUT);    
}

Include Library Path

We will learn how to include Library Path in your project

1. Specify 'Include Path' for your Project Target

Open Options for Target (press ALT+F7) > C/C++ tab > Include Paths

Add the path location for the include files.

2. Create a New Group folder and rename

  1. Right-click on the Project>Target1. Then, select Add Group

  2. Rename the New Group by going to Manage Project Items.

  3. Change the name such as "Include"

3. Specify 'Include Path' for your Include

  1. Right-Click on Project> Include> Options for Group 'New Group'

  2. Options for Group 'Include' > C/C++ Tab> Include Paths> choose where the header files are located

Options for Group, NOT Target1

4. **Add Existing Header files **

Project> Include > Add Existing Files to Group

Also, you can add more files

5. Run the project and see results

You can refer to

Create a new program file as TU_CreateProject_main.c. This is the same file used in

image
image
image

Add your libraries, such

image
Tutorial: Create a Project with uVision
Tutorial: Create a Project with uVision
ecSTM32_simple.h, ecSTM32_simple.c
Library header files
ecSTM32_simple.h
ecSTM32_simple.c
ecPinNames.h
ecPinNames.c