Embedded Programming Laboratory

1y ago
10 Views
2 Downloads
1.53 MB
72 Pages
Last View : 1d ago
Last Download : 3m ago
Upload by : Ronan Garica
Transcription

EMBEDDED PROGRAMMING LABORATORYLAB MANUALCourse Code:BESB09Regulations:IARE - R18ClassBranch::I SemesterM.TECH(ES)Prepared ByMs. M. SUGUNA SRIAssistant Professor, ECEDepartment of Electronics & Communication EngineeringINSTITUTE OF AERONAUTICAL ENGINEERING(Autonomous)Dundigal – 500 043, Hyderabad1

INDEXName of the ContentS. NoPAGE NO.1Lab Objective32Introduction About Lab43LAB CODE54List of Lab Exercises65Description about ES Concepts76Programs List137References822

Lab Objective:An embedded system is some combination of computer hardware and software, either fixed incapability or programmable, that is specifically designed for a particular kind of application device.Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vendingmachines, and toys (as well as the more obvious cellular phone and PDA) are among the myriad possiblehosts of an embedded system. Embedded systems that are programmable are provided with aprogramming interface, and embedded systems programming is a specialized occupation.An embedded system is a special-purpose computer system designed to perform one or a fewdedicated functions, often with real-time computing constraints. It is usually embedded as part of acomplete device including hardware and mechanical parts. In contrast, a general-purpose computer, suchas a personal computer, can do many different tasks depending on programming. Embedded systems havebecome very important today as they control many of the common devices we use.Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing thesize and cost of the product, or increasing the reliability and performance. Some embedded systems aremass-produced, benefiting from economies of scale.3

INTRODUCTION ABOUT LABThere are 30 systems (Dell) installed in this Lab. Their configurations are as follows:Processor:Intel(R) core (TM) - i3 -4150CPU RAM:4 GBHard Disk:500 GBMouse:Optical MouseNetwork Interface card:PresentSoftware1All systems are configured in DUAL BOOT mode i.e, Students can boot from Windows 07.Thisis very useful for students because they are familiar with different Operating Systems so that they canexecute their programs in different programming environments.2Each student has a separate login for database access3Software installed: Keil Micro vision, OFFICE-07, Systems are provided for students in the1:1ratio.4Systems are assigned numbers and same system is allotted for students when they do the lab.4

LAB CODE1. Students should report to the concerned labs as per time table schedule.2. Students who turn up late to the labs will in no case be permitted to do the program scheduled for the day.3. After completion of the program, certification of the concerned staff in-charge in the observation book isnecessary.4. Students should bring a notebook of about 100 pages and should enter the reading/observations into5.the notebook while performing the experiment.6.The record of observations along with the detailed experimental procedure of the experiment performedin the immediate last session should be submitted and certified by the staff member in-charge.7.Not more than three students in a group are permitted to perform the experiment on a setup.8.The group-wise division made in the beginning should be adhered to and no mix up student amongdifferent groups will be permitted later.9.The components required pertaining to the experiment should be collected from stores in-charge afterduly filling in the requisition form.10. When the experiment is completed, students should disconnect the setup made by them, and shouldreturn all the components/instruments taken for the purpose.11. Any damage of the equipment or burn-out of components will be viewed seriously either by puttingpenalty or by dismissing the total group of students from the lab for the semester/year.12. Students should be present in the labs for the total scheduled duration.13. Students are required to prepare thoroughly to perform the experiment before coming to Laboratory.14. Procedure sheets/data sheets provided to the student‘s groups should be maintained neatly and to bereturned after the experiment.5

List of Lab ExcercisesEMBEDDED PROGRAMMING LABORATORY – Lab Programs ListSubmission – 1Week – 1Program to toggle all the bits of port P1 continuously with 250 ms delay.Week – 2Program to interface a switch and a buzzer to two different pins of a port such that the buzzershould sound as long as the switch is pressed.Week – 3Program to interface LCD data pins to port P1 and display a message on itWeek – 4Program to interface seven segment display using 89V51RD2Week – 5Program to interface keypad. Whenever a key is pressed, it should be displayed on LCDWeek – 6Program to transmit message from microcontroller to PC serially using RS232Program to receive a message from PC to microcontroller serially using RS232Week – 7Program to interface Stepper Motor to rotate the motor in clockwise and anticlockwiseDirectionsWeek – 8Program to read data from temperature sensor and display the temperature valueWeek – 9Port RTOS on to 89V51 Microcontroller and verify. Run 2 to 3 taskssimultaneously on 89V51 SDK. Use LCD interface, LED interface,Serial communication.Week – 10Week – 11Week – 12Program to convert analog signal into digital (ADC).Program to convert Digital into Analog (DAC).Program to interface Elevator.6

Description about ES Concepts:Embedded systems are designed to do some specific task, rather than be a general-purpose computer formultiple tasks. Some also have real-time performance constraints that must be met, for reason such assafety and usability; others may have low or no performance requirements, allowing the system hardwareto be simplified to reduce costs. Embedded systems are not always separate devices. Most often they arephysically built-in to the devices they control.The software written for embedded systems is often called firmware, and is stored in read-only memoryor Flash memory chips rather than a disk drive. It often runs with limited computer hardware resources:small or no keyboard, screen, and little memory. Embedded systems range from no user interface at all— dedicated only to one task — to full user interfaces similar to desktop operating systems in devicessuch as PDAs. Simple embedded devices use buttons, LEDs, and small character- or digit-only displays,often with a simple menu system.Embedded Systems components:7

Introduction to 8051 Microcontroller: Microcontroller is a device which integrates number of components of a microprocessor system onto asingle chip. It typically includes:CPU (Central Processing unit)RAM & ROMI/O inputs & outputs – Serial & ParallelTimersInterrupt ControllerBy including the features that are specific to the task (Control), Cost is relatively low.Microcontroller are a ―one chip solutions‖ which drastically reduces parts count and design costs.Block Diagram:8051 Basic Components: 4K bytes internal ROM128 bytes internal RAMFour 8-bit I/O ports (P0 - P3).Two 16-bit timers/countersOne serial interface8

8051 features: 4K bytes ROM 128 bytes RAMFour 8-bit I/O portsTwo 16-bit timersSerial interface64K external code memory spaceALUWorking RegistersClock CircuitsTimers and CountersSerial Data Communication.8051 CPU Registers: A (8-bit Accumulator) B (8-bit register for Mul &Div) PSW (8-bit Program Status Word) SP (8-bit Stack Pointer) PC (16-bit Program Counter) DPTR (16-bit Data Pointer)Pin Description of the 8051: The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O 24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or datebus.9

8051 Development Board(P89V51RD2)On board Peripherals:1) hex-key pad3) serial peripheral interface (spi)5) analog to digital converter7) digital to analog converter9) eeprom (i2c)11) lcd display13) lcd contrast (potentiometer)15) crystal oscillator17) serial port connector19) buzzer21) push button switches23) ps/2 connector25) power supply slide switch27) 7805 voltage regulator29) relay2) seven segment display4) led‘ display6) lm35 temperature sensor8) rtc battery10) rtc12) gnd and vcc14) p89v51rd216) max23218) stepper motor driver20) reset button22) slide switches24) relay output connector26) power jack28) bridge rectifierOverview:The UTS-MC-KIT-M7.3 has got P89V51RD2 microcontroller which has got 64KiloBytes of onchip Flash memory and 1 KiloBytes of RAM. The kit is has got on board 11.0592MHz crystal forgenerating the on chip clock of 11.0592MHz.A Key feature of the board is it has got so many interfaces, with different on board peripheralsand has got expansion capability to add any further sensor and peripherals in future. This prototype boardis very easy to use for 8051 architecture. This board is interfaced with LED‘s, 7 SEG display, LCDdisplay, Pushbutton. This Board can also be interfaced with PC via serial communication and can beviewed through hyper terminal. The LCD display can be connected easily through connectors. Nosoldering work /No lose contact/ just plug in the berg connectors.The board has got on chip peripherals like on board 32 KB bytes of RAM, Eight Light EmittingDiodes, four Push Buttons, Four Seven Segment Displays, 16X2 Liquid Crystal Character Display(LCD),Analog to Digital Converter, LM35 Temperature sensor, SPI based ADC, Hex Keypad, Buzzer relay,steeper motor driver interface, Real time clock, RS-232 serial interface.10

Component Description:MicrocontrollerThe P89V51RD2 device contains a non-volatile 64KB Flash program memory.In-System Programming (ISP) allows the user to download new code while the microcontroller sits inthe application. A default serial loader (boot loader) program in ROM allows serial In-Systemprogramming of the Flash memory via the UART withoutthe need for a loader in the Flash code.This device executes one machine cycle in 6 clock cycles, hence providing twice the speed of aconventional 80C51. An OTP configuration bit lets the user select conventional 12 clock timing if desired.This device is a Single-Chip 8-Bit Micro controller manufactured in advanced CMOS process and is aderivative of the 80C51 micro controller family. The instruction set is 100% compatible with the 80C51instruction set.The device also has four 8-bit I/O ports, three 16-bit timer/event counters, a multisource, and fourpriority-level, nested interrupt structure, an enhanced UART and on-chip oscillator and timing circuits.The added features of the P89V51RD2 makes it a powerful micro controller for applications that requirepulse width modulation, high-speed I/O and up/down counting capabilities such as motor control.Experimental Procedure for Keil4 IDE(For all the experiments this procedure is same)The RVision IDE is, for most developers, the easiest way to create embedded system programs.This chapter describes commonly used RVision features and explains how to use them.RVision is a Windows application that encapsulates the Keil microcontroller development toolsas well as several third-party utilities. RVision provides everything you need to start creating embeddedprograms quickly. RVision includes an advanced editor, project manager, and make utility, which worktogether to ease your development efforts, decreases the learning curve, and helps you to get started withcreating embedded applications quickly.There are several tasks involved in creating a new embedded project: Creating a Project FileUsing the Project WindowsCreating Source FilesAdding Source Files to the ProjectUsing Targets, Groups, and FilesSetting Target Options, Groups Options, and File OptionsConfiguring the Startup CodeBuilding the ProjectCreating a HEX FileThe below section provides a step-by-step tutorial that shows you how to create an embedded projectusing the RVision IDE.11

Downloading the hex file to the target using Flash magic Software:Open the Flash Magic tool for downloading into the Microcontroller Board. Click on Device menu selectoption you will be popped up with a window named choose device. Under choose device options select8051 and click on Ok button to open flash magic tool to download the hex file in to the MCTerminal Software for Check the Serial port Data receiving from Microcontroller to PC:Terminal is a simple serial port (COM) terminal emulation program. It can be used for communicationwith different devices such as modems, routers, embedded microcontroller systems, GSM phones, GPSmodules. It is very useful debugging tool for serial communication applications.12

13

14

EXPERIMENT – 1Aim:Write a Embedded C Program to toggle all the bits of Port P1 continuously with 250 mSdelay led blink with 89V51RD2 microcontroller boardEquipment Requirements:a) Hardware Requirements :1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.b) Software Requirements:1. Flash Magic tool.2. Keil evaluation softwareLEDs Interfacing with 8051:- 22 -

Source code:/* Program to toggle all the bits of Port P1 continuously with 250 mS delay. */#include REG51.H #define LEDPORT P1void delay(unsigned int); voidmain(void){LEDPORT 0x00;while(1){LEDPORT 0X00;delay(250); LEDPORT 0x11;delay(250);}}void delay(unsigned int itime){unsigned int i,j;for(i 0;i itime;i ){for(j 0;j 250;j );}}Flow Chart:- 23 -

Hardware configuration: Connect an 8 pin bus from Port 1 (P1) to the LED pins (No 3 pin strip) or place an 8 pinJumper connecting No2 and No3 pin strips. Turn Off and On the Board or just reset it to view the output.Results/Output verification:Now the led program is running on Microcontroller. And the output can be seen in theboard. You can see led toggling- 24 -

- 25 -

EXPERIMENT – 2Aim:Write a Embedded C Program to interface a switch and a buzzer to two different pins of a port suchthat the buzzer should sound as long as the switch is pressed.Equipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Rquirements :1. Keil2.evaluation softwareFlash Magic tool.Interfacing Switch & Buzzer with 8051:- 26 -

Source code:/*Program to interface a switch and a buzzer to two different pins of a Port such that thebuzzershould sound as long as the switch is pressed.*/#include REG51.H // special function register declarations for the intended 8051derivativesbit SW1 P1 4;sbit BUZZER P3 6;void main (void){BUZZER 0;while(1){if(SW1 0){BUZZER 1;}elseBUZZER 0;}}Flow Chart:- 27 -

Hardware configuration:1. Connect a single pin wire from PORT 1.4 to any switch available on board.2. Place the jumper at jp6 jumper position to connect the buzzer onboard to the controller.3. Turn ON and OFF or reset the board, to view the output.Results/Output verification:After programming the code into the microcontroller just reset the microcontroller. You canlisten to the buzzer buzzing.- 28 -

EXPERIMENT – 3Aim:Write a Embedded C Program to interface LCD data pins to port P1 and display a messageon it using 89V51RD2Equipment Requirements:Hardware Requirements :1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Requirements :1. Keil2.evaluation softwareFlash Magic tool.Interfacing 16*2 LCD with 8051:- 29 -

Source code:/*Program to interface LCD data pins to port P1 and display a message on it.*/#include reg51.h #include "lcd.h" // refer LCD.H code for more to about LCDvoid Delay sec(unsigned char s);main( ){LCD init();while(1){LCD clear();Delay sec(1);LCD row1();LCD puts(" welcome come to embedded lab ");LCD row2();LCD puts(" iare ");Delay sec(5);LCD clear();Delay sec(1);LCD clear();LCD row1();LCD puts("EMEBEDDED SYSTEMS ");LCD row2();LCD puts("AERONAUTICAL ENGG.");Delay sec(5);}}void Delay sec(unsigned char s){unsigned char n;for (n 0; n s; n ){LCD delay(250);LCD delay(250);}}- 30 -

Hardware configuration and Realization:1. Connect a 6 pin jumper or 6 pin bus from PORT 2 to LCD module available on board.2. Turn ON and OFF or reset the board, to view the output.Results/Output verification:After programming the code into the microcontroller just reset the microcontroller. You can see thetext on the LCD.- 31 -

EXPERIMENT – 4Aim:Write a Embedded C Program to interface seven segment display using 89V51RD2Equipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Requirements :1. Keil2.evaluation softwareFlash Magic tool.INTERFCAING SEVEN SEGMENT DISPLAY WITH 8051:- 32 -

Source code:/*Program to interface seven segment display unit.*/#include REG51.H #include stdio.h #define LEDPORTP0sbit CTRL0 P1 0;sbit CTRL1 P1 1;sbit CTRL2 P1 2;sbit CTRL3 P1 600x70void Delay(void);void main (void){CTRL0 1;CTRL1 1;CTRL2 1;CTRL3 1;while(1){LEDPORT ZERO;Delay();LEDPORT ONE;Delay();LEDPORT TWO;Delay();- 33 -

LEDPORT THREE;Delay();LEDPORT FOUR;Delay();LEDPORT FIVE;Delay();LEDPORT SIX;Delay();LEDPORT SEVEN;Delay();LEDPORT EIGHT;Delay();LEDPORT NINE;Delay();LEDPORT TEN;Delay();LEDPORT ELEVEN;Delay();LEDPORT TWELVE;Delay();LEDPORT THIRTEEN;Delay();LEDPORT FOURTEEN;Delay();LEDPORT FIFTEEN;Delay();}}void Delay(void){int j;int i;for(i 0;i 30;i ){for(j 0;j 10000;j ){}}}- 34 -

HARWARE CONFIGURATION:To check the output connects the wires as shown and press any key from the keypad that value shouldbe displayed on seven segments.Result:Output shown on the seven segment display- 35 -

EXPERIMENT – 5Aim:Write a Embedded C Program to 4*4 interface keyboard. Whenever a key is pressed, it should bedisplayed on LCD using 89V51RD2Equipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Requirements:1. Keil2.evaluation softwareFlash Magic tool.4*4 Matrix keyboard interfacing with 8051:- 36 -

Source code:/*Program to interface keypad. Whenever a key is pressed, it should be displayed on LCD.*/#include reg51.h #include"lcd.h"sbit C1 P1 0;sbit C2 P1 1;sbit C3 P1 2;sbit C4 P1 3;sbit R1 P1 4;sbit R2 P1 5;sbit R3 P1 6;sbit R4 P1 7;unsigned char key;void Delay(unsigned int);void delay(){unsigned int i;for (i 0; i 10; i );}/* For 1 ms */unsigned char READ SWITCHES (void)// initialize the port for inputs{// P1.0 to p1.3 are outpot; and P1.4 to P1.7 are inputs// the keybad is connected to port 1// make all rows 1R4 1;R3 1;R2 1;R1 0;//test row 1if (C1 0){// key 1 is preseddelay();//debouncewhile (C1 0);//wait until release the keyreturn 1;}if (C2 0){//key 2 is presseddelay();//debouncewhile (C2 0);//wait until release the key- 37 -

return 2;}if (C3 0){delay();while (C3 0);return 3;}if (C4 0){delay();while (C4 0);return 4;}//test row 2//key 3 is pressed//debounce//wait until release the key//key 4 is pressed//debounce//wait until release the keyR4 1;R3 1;R2 0;R1 1;if (C1 0){//key 5 is presseddelay();//debouncewhile (C1 0);//wait until release the keyreturn 5;}if (C2 0){//key 6 is presseddelay();//debouncewhile (C2 0);//wait until release the keyreturn 6;}if (C3 0){//key 6 is presseddelay();//debouncewhile (C3 0);//wait until release the keyreturn 7;}if (C4 0){//key 7 is presseddelay();//debouncewhile (C4 0);//wait until release the keyreturn 8;}//test row 3- 38 -

R4 1;R3 0;R2 1;R1 1;if (C1 0){//key 8 is presseddelay();//debouncewhile (C1 0);//wait until release the keyreturn 9;}if (C2 0){//key 9 is presseddelay();//debouncewhile (C2 0);//wait until release the keyreturn 10;}if (C3 0){//key A is presseddelay();//depouncewhile (C3 0);//wait until release the keyreturn 11;}if (C4 0){//key B is presseddelay();//depouncewhile (C4 0);//wait until release the keyreturn 12;}//test row 4R1 1;R2 1;R3 1;R4 0;if (C1 0){delay();while (C1 0);return 13;}if (C2 0){delay();while (C2 0);return 14;//key C is pressed//depounce//wait until release the key//key D is pressed//depounce//wait until release the key- 39 -

}if (C3 0){//key E is presseddelay();//depouncewhile (C3 0);//wait until release the keyreturn 15;}if (C4 0){//key C is presseddelay();//depouncewhile (C4 0);//wait until release the keyreturn 16;}return 0;// Means no key has been pressed}void main (void){P1 0x0f;P3 0x00;LCD init();LCD row1();LCD puts(" SERIAL KEYPAD ");LCD row2();LCD puts(" INTERFACING ");Delay(3);while(1){key READ SWITCHES();if(key){P3 key-1;LCD clear();LCD row1();LCD puts(" SERIAL KEYPAD ");LCD row2();LCD puts("KEY : ");switch(key){case 1:{LCD putc('0');break;- 38 -

}case 2:{LCD putc('1');break;}case 3:{LCD putc('2');break;}case 4:{LCD putc('3');break;}case 5:{LCD putc('4');break;}case 6:{LCD putc('5');break;}case 7:{LCD putc('6');break;}case 8:{LCD putc('7');break;}case 9:{LCD putc('8');break;- 39 -

}case 10:{LCD putc('9');break;}case 11:{LCD putc('A');break;}case 12:{LCD putc('B');break;}case 13:{LCD putc('C');break;}case 14:{LCD putc('D');break;}case 15:{LCD putc('E');break;}}case 16:{- 40 -

LCD putc('F');break;}// switch}//if}//while}//mainvoid Delay(unsigned int duration){unsigned int r2;for (r2 0; r2 duration;r2 ){LCD delay(250);LCD delay(250);}}Hardware configuration and realization:1. Connect a 6 pin jumper or 6 pin bus from PORT 2 to LCD module available on board.2. Connect 8 pin jumper to the hex keypad module on the board.3. Turn ON and OFF or reset the board, to view the output.Results/Output verification:After programming the code into the microcontroller just reset the microcontroller. You canlisten to the buzzer buzzing.- 41 -

- 42 -

EXPERIMENT – 6(a)Aim:Write an Embedded C program for serial communication between Microcontroller to PC.Program to transmit message from microcontroller to PC serially using RS232.Equipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Requirements:1. Keil2.evaluation softwareFlash Magic tool.3. TerminalInterfacing Serial communication between MCU to PC:- 43 -

Basic Theory of 8051 Serial commutations:UART (Universal Asynchronous Receiver and Transmitter)One of the microcontroller features making it so powerful is an integrated UART, better known as a serialport. It is a full-duplex port, thus being able to transmit and receive data simultaneously and at differentbaud rates. Without it, serial data send and receive would be an enormously complicated part of theprogram in which the pin state is constantly changed and checked at regular intervals. When using UART,all the programmer has to do is to simply select serial port mode and baud rate. When it's done, serial datatransmit is nothing but writing to the SBUF register, while data receive represents reading the sameregister. The microcontroller takes care of not making any error during data transmission.Serial port must be configured prior to being used. In other words, it is necessary todetermine how many bits is contained in one serial ―word‖, baud rate and synchronization clock source.The whole process is in control of the bits of the SCON register (Serial Control).SM0 - Serial port mode bit 0 is used for serial port mode selection.SM1 - Serial port mode bit 1.SM2 - Serial port mode 2 bit, also known as multiprocessor communication enable bit.TI - Transmit Interrupt flag is automatically set at the moment the last bit of one byte is sent. It's a signalto the processor that the line is available for a new byte transmit. It must be cleared from within thesoftware.RI - Receive Interrupt flag is automatically set upon one byte receive. It signals that byte is received andshould be read quickly prior to being replaced by a new data. This bit is also cleared from within thesoftware.- 44 -

SM0SM1Mode DescriptionBaud Rate0008-bit Shift Register0118-bit UARTDetermined by the timer 11029-bit UART1/32 the quartz frequency (1/641/12 the quartz frequencythe quartz frequency)1139-bit UARTDetermined by the timer 1Source code:/*Program to transmit a message from Microcontroller to PC serially using RS232.*/#include REG51.h /* define 8051 registers */void SendChar(unsigned char x);void DisplayMesPC(unsigned char *);void serial init(void);unsigned char *mes;void main (void)/* main program start */{serial init();mes "\r\nInstitute of Aeronautical engg\r\n\r\nWelcome to Serialcommunication Demo \r\n";DisplayMesPC(mes);mes "\r\nif above txt visible, then transmission sucess\r\n";- 45 -

DisplayMesPC(mes);while(1);}void SendChar(unsigned char x)// transmit function to send character to PC{SBUF x;// wrting the character into the serial bufferTI 0;// Clearing the Transmit empty flagwhile(!TI);// wating for end of trasmission. after transmissionthe TI flag will set.}void DisplayMesPC(unsigned char *mes){int counter;for (counter 0;mes[counter]! '\0';counter ){SendChar(mes[counter]);}}void serial init(){TMOD 0x20;/* GATE OFF,C/#T 0, M1 M0 10(8 BIT AUTORELOAD) TIMER 0 ,TIMER 1 IN MODE 2(AUTO RELOAD MODE)*/SCON 0x50;/* SERIAL PORT IN MODE2 8-BIT UART VARIABLEBAUDRATE */TH1 0xfd;TR1 1;/* TIMER 1 FOR BAUD RATE GEN(9.6K)*//* baud rate timer start*/}- 46 -

Flow chart:Results/Output verification:Now the program is running on Microcontroller. And the output can be seen in the board. Youcan see terminal device .- 47 -

EXPERIMENT – 6(b)Aim:Write an Embedded C program for serial communication between Microcontroller to PC.Program to receive a message from PC to microcontroller serially using RS232.Equipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.Software Requirements:1. Keil2.evaluation softwareFlash Magic tool.3. TerminalInterfacing Serial communication between MCU to PC:- 48 -

Basic Theory of 8051 Serial commutations:UART (Universal Asynchronous Receiver and Transmitter)One of the microcontroller features making it so powerful is an integrated UART, better known as a serialport.It is a full-duplex port, thus being able to transmit and receive data simultaneously and at different baudrates. Without it, serial data send and receive would be an enormously complicated part of the programin which the pin state is constantly changed and checked at regular intervals. When using UART, all theprogrammer has to do is to simply select serial port mode and baud rate. When it's done, serial datatransmit is nothing but writing to the SBUF register, while data receive represents reading the sameregister. The microcontroller takes careof not making any error during data transmission.Serial port must be configured prior to being used. In other words, it is necessary todetermine how many bits is contained in one serial ―word‖, baud rate and synchronization clock source.The whole process is in control of the bits of the SCON register (Serial Control).SM0 - Serial port mode bit 0 is used for serial port mode selection.SM1 - Serial port mode bit 1.SM2 - Serial port mode 2 bit, also known as multiprocessor communication enable bit.TI - Transmit Interrupt flag is automatically set at the moment the last bit of one byte is sent. It's asignalto the processor that the line is available for a new byte transmit. It must be cleared from within thesoftware.RI - Receive Interrupt flag is automatically set upon one byte receive. It signals that byte is receivedandshould be read quickly prior to being replaced by a new data. This bit is also cleared from within thesoftware.SM0SM100Mode Description08-bit Shift RegisterBaud Rate1/12 the quartz frequency- 49 -

001111138-bit UARTDetermined by the timer 12 9-bit UART1/32 the quartz frequency9-bit UARTDetermined by the timer 1Source code:/*Program to receive a message from PC to microcontroller serially using RS232.*/#include reg51.h unsigned char ReceiveSerial() {unsigned char c;TMOD 0x20;/* configure timer for the correct baud rate*/ TH1 0xe6;1200 bps for 12 MHz clock */TCON 0x00; /* Set timer to not running */SCON 0x50; /* Set Serial IO to receive and normal mode */ TR1 1;start timer to Receive */while( (SCON & 0x01) 0 ) /* wait for receive data */;c SBUF;return c;}void main(void) {unsigned char c;while( 1 ){char ReceivSerial()}}- 50 -/*/*

Flow chart:Results/Output verification:Now the program is running on Microcontroller. And the output can be seen in the board.- 51 -

EXPERIMENT – 7Program to interface Stepper Motor to rotate the motor in clockwise and anticlockwise directionsAim:Write a Embedded C Program to interface Stepper Motor to rotate the motor in clockwise andanticlockwise directionsEquipment Requirements:Hardware Requirements:1. 89V51RD2 Development board2. A serial 9 pin cable wired one to one from female connector to male connector3. PC with serial port4. 9V adaptor5. Connecting jumper and Connecting Wires.6.Stepper motorSoftware Requirements:1. Keil2.evaluation softwareFlash

programming interface, and embedded systems programming is a specialized occupation. An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts.

Related Documents:

2. Embedded systems Vs General Computing system Page 4 Sec 1.2 ; 3. History of embedded systems , classification of embedded system Page 5,6 Sec 1.3 , Sec 1,4 . 4. Major application area of embedded sys Page 7 Sec 1.5 5. Purpose of embeded system Page 8 Sec 1.6 6. Typical Embedded sys: Core of embedded system Page 15 Chap 2 : 7. Memory Page 28

CPE 325: Embedded Systems Laboratory Laboratory #1 Tutorial Introduction to TI Code Composer Studio (IDE) Aleksandar Milenković Email: milenka@uah.edu . Environment (IDE) that will be used for software development in the Embedded Systems Laboratory. In the form of a step-by-step tutorial, it demonstrates a typical development cycle .

As embedded systems are getting popular in industrial prod-uct designs, a dedicated teaching laboratory for embedded systems (EST Lab) has been setup for college and graduate students to get familiar with embedded system engineering and researches. In this paper, we present our experiences in embedded system education curriculum and teaching labo-

CO4: Investigate case studies in industrial embedded systems Introduction to Embedded systems, Characteristics and quality attributes (Design Metric) of embedded system, hardware/software co-design, Embedded micro controller cores, embedded memories, Embedded Product development life cycle, Program modeling concepts: DFG, FSM, Petri-net, UML.

The Heart of Java SE Embedded: Customize Your Runtime Environment Embedded Systems: The Wave of the Future Embedded systems are computer-based bu t unlike desktop computers and their applications. An embedded system's computer is embedded in a device. The variety of devices is expanding daily.

The network embedded system is a fast growing area in an embedded system application. The embedded web server is such a system where all embedded device are connected to a web server and can be accessed and controlled by any web browser. Examples; a home security system is an example of a LAN networked embedded system .

CPE 325: Embedded Systems Laboratory Laboratory #3 Tutorial Digital I/O on Experimenter's Board: LEDs and Switches Aleksandar Milenković Email: milenka@uah.edu . Often, we would like to trigger a certain task in embedded systems by pressing a button or switch. Here we will learn how to interface a switch, how to detect that it is pressed .

Abstract- Abrasive Water Jet Machining (AWJM) is a versatile machining process primarily used to machine hard and difficult to machine materials. The objective of this paper is to optimize material removal rate and kerf width simultaneously using AWJM process on INCONEL 718. The process parameters are chosen as abrasive flow rate, pressure, and standoff distance. Taguchi Grey Relational .