Presentation is loading. Please wait.

Presentation is loading. Please wait.

Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.

Similar presentations


Presentation on theme: "Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials."— Presentation transcript:

1 Development

2 Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials Evaluation

3 Aspects of C for Embedded Systems Declarations The const and volatile qualifications are critical, particularly to define special function registers. Their addresses must be treated as constant but the contents are often volatile. const: Means that the value should not be modified: It is constant. volatile: Means that a variable may appear to change “spontaneously,” with no direct action by the user’s program. The compiler must therefore not keep a copy of the variable in a register for efficiency (like a cache). Nor can the compiler assume that the variable remains constant when it optimizes the structure of the program—rearranging loops, for instance. If the compiler did either of these, the program might miss externally induced changes to the contents of the memory associated with the variable.

4 Shifts Low-Level Logic Operations The Boolean form, such as the AND operation in if (A && B), treats A and B as single Boolean values. In contrast, the bitwise operator & acts on each corresponding pair of bits in A and B individually.

5 Masks to Test Individual Bits Bit 3 of the byte P1IN, abbreviated to P1IN.3, for which we can use the standard definition BIT3 = 00001000. A pattern used for selecting bits is called a mask and has all zeroes except for a 1 in the position that we want to select. Always test masked expressions against 0. Masks can also be used to modify the value of individual bits. Clearing a bit (to 0) is done using AND. P1OUT &= ˜BIT3. P1OUT |= BIT3. P1OUT ˆ= BIT3 toggles P1OUT.3.

6 Sizes and Types of Variables The MSP430 is a 16-bit processor so it is likely that a char will be 1 byte and an int will be 2 bytes. Use the definitions in stdint.h. This provides types such as int8_t and uint8_t for signed and unsigned 8-bit integers, respectively. Most variants of the MSP430 have no hardware for multiplication or division, so these operations are slow. Floating-point arithmetic is very expensive on a small microcontroller in terms of both storage and execution. It is better avoided where possible.

7 Layout of Assembly Language RESET: mov.w # WDTPW | WDTHOLD,& WDTCTL ; Stop watchdog timer label: operation operands ; Comment The four parts are 1.label—starts in the first column and may be followed by a colon (:) for clarity. 2.operation—either an instruction, which is translated into binary machine code for the processor itself, or a directive, which controls the assembler. 3.operands—data needed for this operation (not always required). 4.comment—the rest of the line, following a semicolon (;). Hexadecimal; 0xA5 is widely accepted by assemblers. Other common notations include $A5, h'A5' and 0A5h. Binary numbers; 10100101b or b'00011000'.


Download ppt "Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials."

Similar presentations


Ads by Google