LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY. M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

Similar documents
ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Keypad with LPC2148 ARM

EXPERIMENT NO. 01 CALCULATOR USING PIC16F877

ARM HOW-TO GUIDE Interfacing Relay with LPC2148 ARM

An Example of using Keil uvision3 for creating Keil ARM s Project File

AN Entering ISP mode from user code. Document information. ARM ISP, bootloader

LABORATORY MANUAL EMBEDDED C LABORATORY. M. Tech I Year I Sem R13 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

PLL in LPC2148. Dr.R.Sundaramurthy. Department of EIE / PEC. Pondicherry Engineering College. Dr.R.Sundaramurthy.,M.E.,Ph.D.

ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529

Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil cvision3 Development of ET-ARM STAMP LPC2119 Program with GCCARM and Keil uvision3

ARM HOW-TO GUIDE Interfacing 7SEG with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Buzzer with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

EMBEDDED SYSTEMS LABORATORY

Lab Experiment 9: LCD Display

ARM HOW-TO GUIDE Interfacing I2C-7SEG with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Stepper Motor with LPC2148

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interfacing External Devices using Embedded C Module No: CS/ES/22

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Working with the Embedded Artists LPC2148 evaluation boards

Timers in LPC2148. Dr.R.Sundaramurthy. Department of EIE / PEC. Pondicherry Engineering College. Dr.R.Sundaramurthy.,M.E.,Ph.D.

I2C on the HMC6352 Compass

AN Full-duplex software UART for LPC2000. Document information

Using a Temperature Sensor

LCD. Configuration and Programming

// sets the position of cursor in row and column

Speed Control of a DC Motor using Digital Control

Chapter 8 Interfacing a JHD12864J Graphic Module to AT89S52

{ int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); }

/*Algorithm: This code display a centrifuge with five variable speed RPM by increaseing */

Appendix A: Rack Specification Sheet

A Scheme Interpreter on a Microcontroller

AN LPC2138 extreme power down application note. Document information. LPC2138, extreme power down

EMBEDDED HARDWARE DESIGN. Tutorial Interfacing LCD with Microcontroller /I

I/O Devices & Debugging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ENGI E1112 Department Project Report: Computer Science/Computer Engineering. Ankita Gore, Christina Huang, Shikhar Kumar December 16, 2011

P89V51RD2 Development Board May 2010

MEPCO SCHLENK ENGINEERING COLLEGE, SIVAKASI. Department of Electronics and Communication Engineering COURSE INSTRUCTION MANUAL

Objective: Create an interface to the LCD display, internal timer functions, and interface with the SDRAM memory as well as on chip memory.

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display


Dragon12 LCD Displays Huang Sections 7.8 Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) ATD_10B8C Block User Guide. Dragon12 LCD Display

Laboratory 3 Working with the LCD shield and the interrupt system

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

Lecture (09) PIC16F84A LCD interface LCD. Dr. Ahmed M. ElShafee

ERRATA SHEET INTEGRATED CIRCUITS. Date: 2009 October 14 Document Release: Version 1.2 Device Affected: LPC1768. NXP Semiconductors

AN10184 Connecting a keyboard to the Philips LPC9xx microcontroller

Experiment Objectives. 2. Preparation. 3. Tasks. 3.1 Task A: String to Integer Conversion

Basic Embedded Software C Review Using MPLAB SIM. Loops. Embedded Systems Interfacing. 25 August 2011

Arrays. Dr. Madhumita Sengupta. Assistant Professor IIIT Kalyani

Additional Timer Functionalities. Capture, Compare, PWM

Character Based LCD Module Interface.

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04

Timer0..Timer3. Interrupt Description Input Conditions Enable Flag

Magic 8 Ball. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

How to use RFpro in Packet Mode

DB0-DB16 to pin D0-D13, pin A0-A1 of Arduino RESET to A2

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

Unit 13 Timers and Counters

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Timer Counter and Interrupt. Equation (16 bits counter, Mode 1, 16MHz):

The MC9S12 Timer Input Capture Function

/* ///////////////////////////////////////////////////////////////////////////////////////////////////////REAL- TIME CLOCK MODULE DS1307 */

Q1 Q2 Q3 Q4 Q5 Q6 Total /7.5 /5 /10 /5 /7.5 /5 /40

IMDL Fall 2010 Final Report

C:\CYGNAL\Examples\C8051F02x\C\Edu_Board_Source_Code\Magcard.c

Bachelor of Engineering in Computer and Electronic Engineering

Marten van Dijk, Syed Kamran Haider

Array. Prepared By - Rifat Shahriyar

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut

C:\Documents and Settings\Administrateur\Mes documents\projets Keil\DisplayTech\main.c

C Programming Language

ELECTRICITY THEFT CONTROL USING GSM AND EMIC

ELCT501 Digital System Design Winter Tutorial #11 FPGA Complete Design Flow with LCD Example

6.1. EE 109 Unit 6. LCD Interfacing

Character LCD Interface for ez80acclaim! MCUs

#include <ESP8266WiFi.h> #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> #include <PubSubClient.

LCD AND KEYBOARD INTERFACING

ACCESS SECURITY SYSTEM USING RFID TAG

MICROCONTROLLER SYSTEM CONTROL DESIGN JON PRITCHARD SCOTT VON THUN

LAMPIRAN. 1. Program Alat

Keypad Interfacing. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

The MCU s Pulse. Internal clock or oscillator to synchronize operation. One clock cycle = 1 TOSC = 1/fOSC. t TOSC

Real Time Operating Systems Application Board Details

Engineering Design Lab exercise 2 Nios II Processor Software Development

Write LED display data, in accordance with the address from the display from low to high, from low to high data byte operation.

21. PID control The theory of PID control

Arrays and Loops. Programming for Engineers Winter Andreas Zeller, Saarland University

FACULTY OF ENGINEERING LAB SHEET

bs.c ss.c wifire_bs_comm.h/c wifire_ss_comm.h/c

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

LABORATORY MANUAL. ADVANCED EMBEDDED SYSTEMS M. Tech I Year II Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG.

Embedded Systems and Software

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

ARM HOW-TO GUIDE Interfacing GPS with LPC2148 ARM

C library = Header files + Reserved words + main method

ECE 4510/5530 Microcontroller Applications Week 7

Transcription:

LABORATORY MANUAL EMBEDDED SYSTEMS LABORATORY M. Tech I Year I Sem R15 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG. BALAJI INSTITUTE OF TECHNOLOGY & SCIENCE Laknepally, Narsampet, Warangal 506331

LIST OF EXPERIMENTS Note: Minimum of 10 Experiments have to be conducted 1. Write a simple program to print hello world 2. Write a simple program to show a delay. 3. Write a loop application to copy values from P1 to P2 4. Write a c program for counting the no of times that a switch is pressed & released. 5. Illustrate the use of port header file (port M) using an interface consisting of a keypad and liquid crystal display. 6. Write a program to create a portable hardward delay. 7. Write a c program to test loop time outs. 8. Write a c program to test hardware based timeout loops. 9. Develop a simple EOS showing traffic light sequencing. 10. Write a program to display elapsed time over RS-232 link. 11. Write a program to drive SEOS using Timer 0. 12. Develop software for milk pasteurization system.

1. Write a simple program to print hello world #include <lpc214x.h> #define rs 0x00010000 #define en 0x00020000 void delay_ms(unsigned int t) unsigned int i; for(;t>0;t--) for(i=0;i<13000;i++); void cmd(unsigned char x) unsigned int y; y = x<<18; IOPIN1 = IOPIN1 & 0xFC00FFFF; IOPIN1 = IOPIN1 y; IOCLR1 = rs; IOSET1 = en; delay_ms(10); IOCLR1 = en; delay_ms(10); void lcd_disp(unsigned char x) unsigned int y; y = x<<18;

IOPIN1 = IOPIN1 & 0xFC00FFFF; IOPIN1 = IOPIN1 y; IOSET1 = rs; IOSET1 = en; delay_ms(10); IOCLR1 =en; delay_ms(10); void disp_str(unsigned char *x) while(*x) lcd_disp(*x++); void lcdinit() IODIR1=0x03FF0000; cmd(0x38); cmd(0x01); cmd(0x06); cmd(0x0c); cmd(0x80); int main() IODIR0=0xffffffff; lcdinit(); while(1) cmd(0x80); disp_str("hello world");

2. Write a simple program to show a delay. #include <lpc214x.h> #define led1 0x00000001 // declare led1 is p0.0 #define led2 0x00000002 // declare led2 is p0.1 unsigned char x; void delay_ms(unsigned int t) // delay functiobn unsigned int i; for(;t>0;t--) for(i=0;i<5000;i++); // int main() IODIR0=0x00000003; // declare p0.1 to p0.2 as output pis for leds while(1) // continuous loop IOSET0 =led1; IOSET0 =led2; delay_ms(1000); // upto 1 sec leds are on(1000= 1 sec, if u want 2 sec delay then 2000) IOCLR0 =led1; IOCLR0 =led2; delay_ms(1000); // upto 1 sec leds are off

3. Write a loop application to copy values from P1 to P2 #include <lpc214x.h> unsigned char x; unsigned int y; int main() IODIR0=0x00000000; // declare p0 as input IODIR0=0xffff0000; // declare p as output while(1) // continuous loop x='w'; y = x<<16; // single char 'w' transfer to x variable // valur transfer from p0.16 pin to p0.23(8 bit dat) IOPIN0 = IOPIN0 & 0x00000000; // first clear the all pins that's why we are using and(&) opration with zeros IOPIN0 = IOPIN0 y; // value transfer to port 0 IOPIN1 = IOPIN1 & 0x00000000; // first clear the all pins that's why we are using and(&) opration with zeros IOPIN1 = IOPIN0 ; // value transfer to port 0 to port1

4. Write a c program for counting the no of times that a switch is pressed & released. #include <lpc214x.h> #define sw 1<<0 // p0.0 connected to switch unsigned int pc,rc; //pc= pressed count, rc= released count variables unsigned char x; int main() IODIR0=0x00000000; // declare p0 as input while(1) // continuous loop x=iopin0; // read input value from switch x=x&0x00000001; // if input signal is high that signal & with 1 then output is '1' otherwise '0' if(x==0x00000001) // switch is pressed signal is high then enter this loop while(x==0x00000001); // wait until switch is released pc++; // increment the pressed count else if(x==0x00000000) while(x==0x00000000); // wait until switch is pressed rc++; // increment the released count

5. Illustrate the use of port header file (port M) using an interface consisting of a keypad and liquid crystal display. #include <LPC214X.H> #include "lcd.h" #include "keypad.h" unsigned char arr[4]; int main() IODIR0=0xfff000ff; // declare col as inputs and row as outputs lcdinit(); while(1) to array cmd(0x80); // lcd 1st row display address disp_str("enter VALUES "); cmd(0xc0); // lcd 2 nd row display address for(i=0;i<4;i++) // ENTER 4 VALUES arr[i]=get_key(); // read value from keypad and assign lcd_disp(arr[i]); // display value in array #define C1 0x00020000 //p0.17v col 1 #define C2 0x00040000 //p0.18 col 2 #define C3 0x00080000 //p0.19 col 3 #define RowA 0x00100000 //p0.20 #define RowB 0x00200000 //p0.21 #define RowC 0x00400000 //p0.22 #define RowD 0x00800000 //p0.23 unsigned char key,ch; unsigned int i,j; void dela(int x); void Return(void) cmd(0x02); dela(1500); //Return to 0 location on LCD

char READ_SWITCHES(void) IO0CLR =RowA;IO0SET =RowB;IO0SET =RowC;IO0SET =RowD; //Test Row A if (!(IOPIN0&=C1)) dela(100); while (!(IOPIN0&=C1)); return '1'; IO0CLR =RowA;IO0SET =RowB;IO0SET =RowC;IO0SET =RowD; if (!(IOPIN0&=C2)) dela(100); while (!(IOPIN0&=C2)); return '2'; IO0CLR =RowA;IO0SET =RowB;IO0SET =RowC;IO0SET =RowD; if (!(IOPIN0&=C3)) dela(100); while (!(IOPIN0&=C3)); return '3'; IO0CLR =RowB;IO0SET =RowA;IO0SET =RowC;IO0SET =RowD; //Test Row B if (!(IOPIN0&=C1)) dela(100); while (!(IOPIN0&=C1)); return '4'; IO0CLR =RowB;IO0SET =RowA;IO0SET =RowC;IO0SET =RowD; if (!(IOPIN0&=C2)) dela(100); while (!(IOPIN0&=C2)); return '5'; IO0CLR =RowB;IO0SET =RowA;IO0SET =RowC;IO0SET =RowD; if (!(IOPIN0&=C3)) dela(100); while (!(IOPIN0&=C3)); return '6'; IO0CLR =RowC;IO0SET =RowA;IO0SET =RowB;IO0SET =RowD; //Test Row C if (!(IOPIN0&=C1)) dela(100); while (!(IOPIN0&=C1)); return '7'; IO0CLR =RowC;IO0SET =RowA;IO0SET =RowB;IO0SET =RowD; if (!(IOPIN0&=C2)) dela(100); while (!(IOPIN0&=C2)); return '8'; IO0CLR =RowC;IO0SET =RowA;IO0SET =RowB;IO0SET =RowD; if (!(IOPIN0&=C3)) dela(100); while (!(IOPIN0&=C3)); return '9'; IO0CLR =RowD;IO0SET =RowA;IO0SET =RowB;IO0SET =RowC;//Test Row D if (!(IOPIN0&=C1)) dela(100); while (!(IOPIN0&=C1)); return '*'; IO0CLR =RowD;IO0SET =RowA;IO0SET =RowB;IO0SET =RowC; if (!(IOPIN0&=C2)) dela(100); while (!(IOPIN0&=C2)); return '0'; IO0CLR =RowD;IO0SET =RowA;IO0SET =RowB;IO0SET =RowC; if (!(IOPIN0&=C3)) dela(100); while (!(IOPIN0&=C3)); return '#'; return 'n'; // Means no key has been pressed

char get_key(void) char key = 'n'; //get key from user //assume no key pressed while(key=='n') //wait untill a key is pressed key = READ_SWITCHES(); //scan the keys again and again return key; //when key pressed then return its value void dela(int x) int i,j; for(i=0;i<x;i++) for(j=0;j<200;j++); //null statement #define rs 0x00010000 #define en 0x00020000 void delay_ms(unsigned int t) unsigned int i; for(;t>0;t--) for(i=0;i<13000;i++); void cmd(unsigned char x) unsigned int y; y = x<<18; IOPIN1 = IOPIN1 & 0xFC00FFFF; IOPIN1 = IOPIN1 y; IOCLR1 = rs; IOSET1 = en; delay_ms(10); IOCLR1 = en; delay_ms(10); void lcd_disp(unsigned char x) unsigned int y; y = x<<18;

IOPIN1 = IOPIN1 & 0xFC00FFFF; IOPIN1 = IOPIN1 y; IOSET1 = rs; IOSET1 = en; delay_ms(10); IOCLR1 =en; delay_ms(10); void disp_str(unsigned char *x) while(*x) lcd_disp(*x++); void lcdinit() IODIR1=0x03FF0000; cmd(0x38); cmd(0x01); cmd(0x06); cmd(0x0c); cmd(0x80);

6. Write a program to create a portable hardward delay. #include <lpc214x.h> #define PLOCK 0x00000400 #define PRESCALE 60000 void delayms(unsigned int milliseconds); void initclocks(void); void inittimer0(void); void setuppll0(void); void feedseq(void); void connectpll0(void); int main(void) initclocks(); inittimer0(); IO0DIR = 0xFFFFFFFF; while(1) IO0SET = 0xFFFFFFFF; delayms(500); IO0CLR = 0xFFFFFFFF; delayms(500); //0.5 Second(s) Delay void inittimer0(void) T0CTCR = 0x0; T0PR = PRESCALE-1; T0TCR = 0x02; void delayms(unsigned int milliseconds) T0TCR = 0x02; T0TCR = 0x01;

while(t0tc < milliseconds); T0TCR = 0x00; void initclocks(void) setuppll0(); feedseq(); connectpll0(); feedseq(); VPBDIV = 0x01; void setuppll0(void) PLL0CON = 0x01; PLL0CFG = 0x24; void feedseq(void) PLL0FEED = 0xAA; PLL0FEED = 0x55; void connectpll0(void) while(!( PLL0STAT & PLOCK )); PLL0CON = 0x03;

7. Write a c program to test loop time outs. #include <lpc214x.h> #define sw 1<<0 void testtime_out(unsigned int milliseconds); unsigned char x; int main(void) IO0DIR = 0xFFFFFFFe; while(1) mn: x=iopin0; x=x&0x00000001; if(sw==0x00000001) IO0SET = 0xFFFFFFFF; IO0CLR = 0xFFFFFFFF; testtime_out(1500); //1.5 Second(s) time out loop goto mn; else if(sw==0x00000000) IO0SET = 0xFFFFFFFF; IO0CLR = 0xFFFFFFFF; testtime_out(1500); goto mn; //1.5 Second(s) time out loop void testtime_out(unsigned int milliseconds) // test time out loop unsigned int j; for(;milliseconds>0;milliseconds--) for(j=0;j<5000;j++);

8. Write a c program to test hardware based timeout loops. #include <lpc214x.h> #define PLOCK 0x00000400 #define PRESCALE 60000 #define sw 0x00010000 void delayms(unsigned int milliseconds); void initclocks(void); void inittimer0(void); void setuppll0(void); void feedseq(void); void connectpll0(void); unsigned char timeout_loop=0,x; int main(void) initclocks(); inittimer0(); IO0DIR = 0xFFFeFFFF; while(1) mn: x= IOPIN0; x=x&0x00010000; if(x==0x00010000) do x= IOPIN0; x=x&0x00010000; IO0SET = 0xFFFFFFFF; delayms(1000); // 1 Second(s) Delay IO0CLR = 0xFFFFFFFF; while(x==0x00010000&&t0tcr!=0x00); goto mn; else if(x==0x00000000) do IO0SET = 0xFFFF0000; delayms(1000); // 1 Second(s) Delay IO0CLR = 0x0000FFFF; while(x==0x00000000&&t0tcr!=0x00);

goto mn; void inittimer0(void) T0CTCR = 0x0; T0PR = PRESCALE-1; T0TCR = 0x02; void delayms(unsigned int milliseconds) T0TCR = 0x02; T0TCR = 0x01; while(t0tc < milliseconds); T0TCR = 0x00; timeout_loop++; void initclocks(void) setuppll0(); feedseq(); connectpll0(); feedseq(); VPBDIV = 0x01; void setuppll0(void) PLL0CON = 0x01; PLL0CFG = 0x24;

void feedseq(void) PLL0FEED = 0xAA; PLL0FEED = 0x55; void connectpll0(void) while(!( PLL0STAT & PLOCK )); PLL0CON = 0x03;

10. Write a program to display elapsed time over RS-232 link. #include <lpc214x.h> #define PLOCK 0x00000400 #define PRESCALE 60000 #define sw 0x00010000 void uart0_init(void); void uart0_tx(unsigned char); void str_uart0(unsigned char *x); void delayms(unsigned int milliseconds); void initclocks(void); void inittimer0(void); void setuppll0(void); void feedseq(void); void connectpll0(void); unsigned char timeout_loop=0,x; int main(void) uart0_init(); initclocks(); inittimer0(); IO0DIR = 0xFFFeFFFF; while(1) mn: x= IOPIN0; x=x&0x00010000; if(x==0x00010000) do str_uart0("event 1 is start and time is counting"); x= IOPIN0; x=x&0x00010000; IO0SET = 0xFFFFFFFF; delayms(1000); // 1 Second(s) Delay IO0CLR = 0xFFFFFFFF; while(x==0x00010000&&t0tcr!=0x00); str_uart0("time is 1 sec for event 1is completed, event 1 is lights all are on");

goto mn; else if(x==0x00000000) do str_uart0("event 2 is start and time is counting"); IO0SET = 0xFFFF0000; delayms(2000); // 1 Second(s) Delay IO0CLR = 0x0000FFFF; while(x==0x00000000&&t0tcr!=0x00); str_uart0("time is 2 sec for event 1is completed, event 2 is some lights are on remaining are off "); goto mn; void inittimer0(void) T0CTCR = 0x0; T0PR = PRESCALE-1; T0TCR = 0x02; void delayms(unsigned int milliseconds) T0TCR = 0x02; T0TCR = 0x01; while(t0tc < milliseconds); T0TCR = 0x00; timeout_loop++; void initclocks(void) setuppll0(); feedseq(); connectpll0(); feedseq();

VPBDIV = 0x01; void setuppll0(void) PLL0CON = 0x01; PLL0CFG = 0x24; void feedseq(void) PLL0FEED = 0xAA; PLL0FEED = 0x55; void connectpll0(void) while(!( PLL0STAT & PLOCK )); PLL0CON = 0x03; void uart0_init(void) PINSEL0 =0x00000005; U0LCR=0x83; U0DLL=98; U0DLM=0; U0LCR=0x03; void tx_uart0(unsigned char x) U0THR=x; while(!(u0lsr&=0x20)); void str_uart0(unsigned char *x) while(*x) tx_uart0(*x++);