lec1-4-ProgInC

lec1-4-ProgInC - WPI ECE2801 Foundations of Embedded...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
WPI ECE2801 Foundations of Embedded Computer Systems Lecture 4: Programming in C for MSP430
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE2801: Foundations of Embedded Systems Lecture 4 Review: MSP430 family uses a 16-bit, von Neumann, RISC CPU core. Memory is byte addressable and „F449 has 2KB RAM, 60KB Flash memory, and many on-chip peripherals (memory mapped). 16-bit wide address bus
Background image of page 2
A simple C program #include <stdlib.h> /* include the C standard library */ void main() { float degF, degC, degK; degF = 45.7; degC = 5 * (degF-32)/9; degK = degC + 273.15; } EE2801: Foundations of Embedded Systems Lecture 4
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A simple C program tempOK = 1; degF = get_degF(); while (tempOK > 0) { degF = degF - 10; degC = 5 * (degF-32)/9; degK = degC + 273.15; if (degK < 0) { printf(“ERROR – Temp < 0 K\n”); printf(“Breaking Multiple Laws of Physics!\n”); tempOK = 0; } else printf(“%10.4f F = %10.4f C = %10.4f K \n”, } // loop back to while() EE2801: Foundations of Embedded Systems Lecture 4
Background image of page 4
EE2801: Foundations of Embedded Systems Lecture 4 Variable Declaration Some Data types (as they are defined in IAR Kickstart) int num1,sum,myArray[10]; // 16 bit signed (2's comp) integer float myReal,flt_arr[5]; // 32 bit IEEE floating point char c, name[16]; // 8 bit character unsigned int d; // 16 bit unsigned integer long int e; // 32 bit signed integer double f; // 32 bit in IAR (selectable to 64)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE2801: Foundations of Embedded Systems Lecture 4 Basic Instructions and Syntax
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2009 for the course ECE 2801 taught by Professor Jarvis during the Spring '08 term at WPI.

Page1 / 15

lec1-4-ProgInC - WPI ECE2801 Foundations of Embedded...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online