Header File for Particular MCU[SOLVED]

Thread Starter

Pushkar1

Joined Apr 5, 2021
401
I am curious to know that if you want to create your own header file for a particular MCU what would you put in the header file?

The header file contains information for the compiler. The compiler needs to know what MCU the code is for. Header files are very much compiler specific. Most MCU header files are already created and come with the compiler. In this case we do not need to create header file.

The header file is written first at the beginning of the program. In general, the header file contains the definitions declaration preprocessors.

If you have a datasheet of a particular microcontroller, What sorts of things should you put in header file?

update


C:
#include<MCU.h>

void main (void)
{
  while (1);
}
 
Last edited:

MrChips

Joined Oct 2, 2009
24,592
The header file is not compiler specific.

The purpose of the header file is to define items not already defined by the language specifications, such as language extensions, MCU definitions and application defaults.

There are often multiple header files in a given project. You should have at least two header files:

(1) MCU hardware defines as supplied by the MCU manufacturer,
(2) application constants and default.

In addition, every library should come with header files where function prototypes are declared.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
401
The header file is not compiler specific.
(1) MCU hardware defines as supplied by the MCU manufacturer,
I am looking for the first point, how to create a header file for this

MCU hardware configuration is provided by the manufacturer in the datasheet. such as general input output port configuration, different type of peripheral configurations Timer, UART, SPI, ADC, I2C

What sorts of things should you put in header file for Hardware ?

update


So for header file you can take any microcontroller of your choice
 
Last edited:

MrChips

Joined Oct 2, 2009
24,592
The MCU hardware header file will contain addresses of all hardware peripherals, registers, and names of all bits in all registers. This header file is provided by the MCU manufacturer, IDE supplier or open source community. You normally do not create this yourself.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
401
You normally do not create this yourself.
I agree with you 100 % I don't need to create MCU hardware header file. MCU manufacturer or IDE supplier provide complete header file.

The MCU hardware header file will contain addresses of all hardware peripherals, registers, and names of all bits in all registers.
Thanks for giving accurate information. I will do more research in this regard.
 
Last edited:

Papabravo

Joined Feb 24, 2006
17,228
Why not open one up and look at it? It is just a text file after all.
Another thing it might include are "text substitution macros". These are all evaluated by a pre-processor portion of the the compiler before the actual compiler ever takes it's first look at the source text. In fact it never actually "sees" the original source text, only the output of the pre-processor.
 

Papabravo

Joined Feb 24, 2006
17,228
The pre-processor also strips out ALL of the comments, since they are of no earthly use to the compiler. They are for the human readers of the source code only.
 
Top