CMP EMBEDDED.COM

Login | Register     Welcome Guest  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

An architecture for designing reusable embedded systems software, Part 3
Want to make your application software more reusable? Don't change the hardware, operating system, or your tools. Instead change the architectural framework within which you do your design. Part 3 in the three-part series gives additional elements in the reusable system software architecture.



Embedded.com

As discussed in Part 1 and Part 2 in this series, the ECU_HSIS.H hardware/software-interface specification contains references to three external files that are used to further define the microcontroller architecture: Compiler.H, Microports.H, and Vectors.H. Other essential elements of this architecture include the microcontroller memory map, system-clock definitions, microcontroller peripheral definitions, and hardware/software-interface specification definitions.

COMPILER.H
The information in this file is found in the compiler's handbook and would consist of the following:

• Reassignment of standard C-types

• Compiler numerical size limitations.

• Compiler-specific commands unique to the microprocessor.

Reassignment of standard C types
The assignment of types is dependent on the compiler and/or microcontroller. Reassigning the standard types and using them in the software will speed up the process of switching to another compiler/microcontroller, if the types are different. In one case, an unsigned long integer might take on the shape of 32-bits while in another case the same unsigned integer type might be 16-bits. Defining the bit length in the redefined type eliminates ambiguity. U16 translates to an unsigned data type of 16-bit length.


typedef unsigned char   U8;
typedef signed char     S8;
typedef unsigned short  U16;
typedef signed short    S16;
typedef unsigned long   U32;
typedef signed long     S32;

Compiler numerical size limitations
Variable size limitations define the sizes of the standard data types that are being used in your compiler/microcontroller architecture. The sizes are based upon the new assignment of types and modified if the standard type(s) are changed.


#define MAX_UCHAR       255
#define POS_CHAR_MAX    127
#define NEG_CHAR_MIN    (-128)
#define MAX_USHORT      (0xFFFF)
#define POS_SHORT_MAX   32767
#define NEG_SHORT_MIN   (-32768)
#define MAX_ULONG       (0xFFFFFFFF)

Compiler-specific commands
These commands are specific to your compiler and implemented to provide access to special microcontroller features. For example, each compiler may have explicit ways to handle the definition of interrupt subroutines. One compiler implementation might require the "@" symbol followed by the word "interrupt" before a function statement to define that function as being an Interrupt Subroutine (ISR). The implementations may vary greatly between compiler providers and should be explicitly defined in this header file. Below are some examples of compiler specific commands. These commands are an extension to the programming language standard and provide the software engineer with access to specific embedded microcontroller features.


#define INTERRUPT @interrupt 
//define interrupt subroutine
#define EEPROM	@eeprom
//define eeprom variable storage
#define ASM @asm
//define assembly language inline code

1 | 2 | 3

Rate this article: Low High
Current rating
  • .
Embedded.com Career Center
Looking for a new job?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS





 :