DOC PREVIEW
UNCC ECGR 4101 - Introduction to Embedded Systems

This preview shows page 1-2-3-27-28-29 out of 29 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Introduction to Embedded SystemsLecture 1These lecture notes created by Alex Dean, NCSUTodayWhat Are Embedded Systems?Why Are We ….?Course OverviewIntroduction to Microcontroller-based Circuit DesignEmbedded Systems 1-2Embedded Systems 1-3Definition of an Embedded ComputerComputer purchased as part of some other piece of equipment– Typically dedicated software (may be user-customizable)– Often replaces previously electromechanical components– Often no “real” keyboard– Often limited display or no general-purpose display deviceEmbedded Systems 1-4But, every system is unique -- there are always exceptionsA Customer ViewEmbedded Systems 1-5Reduced CostIncreased FunctionalityImproved PerformanceIncreased Overall DependabilityMicrocontroller and Starter KitMitsubishi Semiconductors is now “Renesas”M16C/26 family of microcontrollers–M30626Embedded Systems 1-6–M30626– 32K RAM, 384K FlashSKP = starter kit MDS = Microcontroller Data Sheet = M16C_Hardware_Manual_Rev0.9.pdfM16C DemonstrationConfiguring I/O ports– Input: switches– Output: LEDsEcho switch state on LEDsHuman response time analysis–How quickly can a person press a switch after seeing a light?Embedded Systems 1-7–How quickly can a person press a switch after seeing a light?Processor response time analysis– How quickly does the processor respond to the switch being pressed?Processor speed evaluation– How much work can the processor do in that time?Source Code#include "stdio.h"#include "stdio.h"#include "stdio.h"#include "stdio.h"#include "sfr626.h"#include "sfr626.h"#include "sfr626.h"#include "sfr626.h"#include "SKP_LCD.h"#include "SKP_LCD.h"#include "SKP_LCD.h"#include "SKP_LCD.h"#define RED_LED (p8_0) /* from board data sheet */#define RED_LED (p8_0) /* from board data sheet */#define RED_LED (p8_0) /* from board data sheet */#define RED_LED (p8_0) /* from board data sheet */#define YEL_LED (p7_4) #define YEL_LED (p7_4) #define YEL_LED (p7_4) #define YEL_LED (p7_4) #define GRN_LED (p7_2) #define GRN_LED (p7_2) #define GRN_LED (p7_2) #define GRN_LED (p7_2) #define LED_ON (0) /* 0 is ON for LEDs (active#define LED_ON (0) /* 0 is ON for LEDs (active#define LED_ON (0) /* 0 is ON for LEDs (active#define LED_ON (0) /* 0 is ON for LEDs (active----low) */low) */low) */low) */#define LED_OFF (1)#define LED_OFF (1)#define LED_OFF (1)#define LED_OFF (1)#define DIR_IN (0)#define DIR_IN (0)#define DIR_IN (0)#define DIR_IN (0)#define DIR_OUT (1)#define DIR_OUT (1)#define DIR_OUT (1)#define DIR_OUT (1)#define SW1 (p8_3)#define SW1 (p8_3)#define SW1 (p8_3)#define SW1 (p8_3)#define SW2 (p8_2)#define SW2 (p8_2)#define SW2 (p8_2)#define SW2 (p8_2)#define SW3 (p8_1)#define SW3 (p8_1)#define SW3 (p8_1)#define SW3 (p8_1)void main () {void main () {void main () {void main () {char buf[9];char buf[9];char buf[9];char buf[9];long int i, r=12345;long int i, r=12345;long int i, r=12345;long int i, r=12345;init_switches();init_switches();init_switches();init_switches();init_LEDs();init_LEDs();init_LEDs();init_LEDs();InitDisplay();InitDisplay();InitDisplay();InitDisplay();#if (1)#if (1)#if (1)#if (1)test_switches();test_switches();test_switches();test_switches();#endif#endif#endif#endifDisplayString(LCD_LINE1, "Response");DisplayString(LCD_LINE1, "Response");DisplayString(LCD_LINE1, "Response");DisplayString(LCD_LINE1, "Response");DisplayString(LCD_LINE2, " Timer ");DisplayString(LCD_LINE2, " Timer ");DisplayString(LCD_LINE2, " Timer ");DisplayString(LCD_LINE2, " Timer ");while(1) {while(1) {while(1) {while(1) {for (i=0; i<200000+(r%50000); i++)for (i=0; i<200000+(r%50000); i++)for (i=0; i<200000+(r%50000); i++)for (i=0; i<200000+(r%50000); i++); ; ; ; i=0;i=0;i=0;i=0;RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;Embedded Systems 1-8void init_switches() {void init_switches() {void init_switches() {void init_switches() {pd8_1 = pd8_2 = pd8_3 = DIR_IN;pd8_1 = pd8_2 = pd8_3 = DIR_IN;pd8_1 = pd8_2 = pd8_3 = DIR_IN;pd8_1 = pd8_2 = pd8_3 = DIR_IN;}}}}void init_LEDs() {void init_LEDs() {void init_LEDs() {void init_LEDs() {pd8_0 = pd7_4 = pd7_2 = DIR_OUT;pd8_0 = pd7_4 = pd7_2 = DIR_OUT;pd8_0 = pd7_4 = pd7_2 = DIR_OUT;pd8_0 = pd7_4 = pd7_2 = DIR_OUT;RED_LED = YEL_LED = GRN_LED = LED_ON; RED_LED = YEL_LED = GRN_LED = LED_ON; RED_LED = YEL_LED = GRN_LED = LED_ON; RED_LED = YEL_LED = GRN_LED = LED_ON; RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; }}}}void test_switches(void) {void test_switches(void) {void test_switches(void) {void test_switches(void) {while (1) {while (1) {while (1) {while (1) {RED_LED = (!SW1)? LED_ON : LED_OFF;RED_LED = (!SW1)? LED_ON : LED_OFF;RED_LED = (!SW1)? LED_ON : LED_OFF;RED_LED = (!SW1)? LED_ON : LED_OFF;YEL_LED = (!SW2)? LED_ON : LED_OFF;YEL_LED = (!SW2)? LED_ON : LED_OFF;YEL_LED = (!SW2)? LED_ON : LED_OFF;YEL_LED = (!SW2)? LED_ON : LED_OFF;GRN_LED = (!SW3)? LED_ON : LED_OFF;GRN_LED = (!SW3)? LED_ON : LED_OFF;GRN_LED = (!SW3)? LED_ON : LED_OFF;GRN_LED = (!SW3)? LED_ON : LED_OFF;}}}}}}}}RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;RED_LED = YEL_LED = GRN_LED = LED_ON;while (SW1)while (SW1)while (SW1)while (SW1)i++;i++;i++;i++;#if (1) #if (1) #if (1) #if (1) sprintf(buf, "%8ld", i);sprintf(buf, "%8ld", i);sprintf(buf, "%8ld", i);sprintf(buf, "%8ld", i);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE2, "iters. ");DisplayString(LCD_LINE2, "iters. ");DisplayString(LCD_LINE2, "iters. ");DisplayString(LCD_LINE2, "iters. ");#else#else#else#elsesprintf(buf, "%8.3f", i*39.1/287674);sprintf(buf, "%8.3f", i*39.1/287674);sprintf(buf, "%8.3f", i*39.1/287674);sprintf(buf, "%8.3f", i*39.1/287674);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE1, buf);DisplayString(LCD_LINE2, "millisec");DisplayString(LCD_LINE2, "millisec");DisplayString(LCD_LINE2, "millisec");DisplayString(LCD_LINE2, "millisec");#endif #endif #endif #endif RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; RED_LED = YEL_LED = GRN_LED = LED_OFF; r=0;r=0;r=0;r=0;while (!SW1) /* wait for switch to


View Full Document

UNCC ECGR 4101 - Introduction to Embedded Systems

Documents in this Course
Load more
Download Introduction to Embedded Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Embedded Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Embedded Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?