EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #30 background imageLoading...
Page #30 background image
30
Building New Libraries
Building new libraries is simple. All we need to do is to follow a few set of rules:
For each module, there should be a separate header file and source file.
Header file should contain definitions, variables, constants and function prototypes only.
Header files should begin with the inclusion of MSP430 header file.
Source files should include their respective header files and addition header files (if any).
Source files should contain actual function codes only.
Be aware of reserved keywords and constants.
Global variables with same names should never be declared more than once.
Empty functions and functions without prototypes must be avoided.
Functions should have small and meaningful names.
Be careful about case-senstivity, function type assignment and argument type of functions.
Hierarchical order of library inclusion must be followed.
delay.h
#include <msp430.h>
#define F_CPU 8
void delay_us(unsigned int value);
void delay_ms(unsigned int value);
delay.c
#include "delay.h"
void delay_us(unsigned int value)
{
register unsigned int loops = ((F_CPU * value) >> 2);
while(loops)
{
_delay_cycles(1);
loops--;
};
}
void delay_ms(unsigned int value)
{
while(value)
{
delay_us(1000);
value--;
};
}

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals