Vous êtes sur la page 1sur 43

LIST OF EXPERIMENTS

DESIGN WITH 16 BIT PROCESSOR –MSP430


 Led flash
 Timer
 Interrupt
 Serial communication-RS 232.
DESIGN WITH 8 BIT MICROCONTROLLERS-8051.
 Led
 Buzzer
 Serial port programming.
 LCD
 Dc motor.
 Timer
DESIGN OF FILTERS.
 Butterworth – low pass digital IIR filter.
 Implementation of low pass FIR filter.
DESIGN AND IMPLEMENTATION OF SIMPLE COMBINATIONAL /
SEQUENTIAL CIRCUITS.
COMBINATIONAL CIRCUITS:
 Half adder & Full adder.
SEQUENTIAL CIRCUITS :
 D-Flip Flop & Shift register.
ADDITIONAL EXPERIMENTS:
 Switch interfacing using 8 bit microcontroller-8051.
 ADC interfacing using 8 bit microcontroller-8051.
Experiment No: 1 LED FLASH
Date:
AIM:
To write an ASM program to flash LED using MSP 430.
EMBEDDED SYSTEM LAB Page 1
SOFTWARE REQUIRED:
 IAR Software
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 MSP430 KIT 1
2 Flash Emulation Tool 1
3 JTAG Cable 1
4 USB Cable 2

PROCEDURE:
1. Go to start- all programs- IAR systems--IAR embedded workbench.
2. Close the IAR information file.
3. Create a project.
4. Select the asm option and click ok
5. Enter the file name &save
6. Delete the basic asm file that is copied and it is shown in below
7. Write the program
8. Save the program. Click on the project name and right click on the project name. Click on
“options” tab.
9. Select general “options tab” under category. Select IC options under “device” tab. Click on the
correct MSP430 IC.
10. After selecting the correct IC click “ok” as shown.
11. In the same above window click “debugger” under category. Select “FET debugger &click
“ok” as shown
12. In the same above window click FET debugger under category. Select Texas instrument USB
–IF under”conections”tab as shown.
13. save the program &click on “Make” icon as shown.
14. Give the file name &save the window as shown
15. Click the messages and it should be display the zero errors for proper error free program
compilation.
16. Click on download and debug icon
17. After downloading the program click ok on the stack warning messages.
18. Click go icon ->->-> as shown.
EMBEDDED SYSTEM LAB Page 2
19. Observe the LED flashing (output varies for the corresponding experiments)in the MSP 430
kit.
PROGRAM:
#include “msp430x14x.h" ; Header file
;-------------------------------------------;
ORG 0E100h ; Progam Start
;-------------------------------------------;
RESET mov.w #01500h,SP ; Initialize 'F161x stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop Watchdog Timer
;-------------------------------------------;

SetupP1 MOV.B #0ffh,&P1DIR ; P1.0 output pin


load MOV.B #0ffh,&P1OUT ; set P1.0
call #Delay_16ms
;-------------------------------------------;
Mainloop XOR.B #0ffH,&P1OUT ; Toggle P1.0
call #Delay_16ms
jmp Mainloop ; Again
;-------------------------------------------;
Delay_16ms mov.w #50000,R15 ; Delay to R15
L1 dec.w R15 ; Decrement R15
jnz L1 ; Delay over?
ret
;-------------------------------------------;
; Interrupt Vectors Used MSP430x161x
;-------------------------------------------;

ORG 0FFFEh ; MSP430 RESET Vector location


DW RESET ; RESET lable
END
;-------------------------------------------;

RESULT:

Thus an ASM program to flash LED using MSP430 has been written and the output is
verified.

EMBEDDED SYSTEM LAB Page 3


Experiment No: 2 TIMER
Date:
AIM:
To write an ASM program to generate square wave for variable frequencies using MSP430.
SOFTWARE REQUIRED:
IAR Software
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 MSP430 KIT 1
2 Flash Emulation Tool 1
3 JTAG Cable 1
4 USB Cable 2

PROCEDURE:
1.Go to start- all programs- IAR systems--IAR embedded workbench.
2.Close the IAR information file
3.Create a project
4.Select the asm option and click ok
5.Enter the file name &save
6.Delete the basic asm file that is copied and it is shown in below
7.Write the program
8.Save the program.Click on the project name and right click on the project name. Click on
“options” tab.
9. Select general “options tab” under category.Select IC options under “device” tab.Click on the
correct MSP430 IC.
10.After selecting the correct IC click “ok” as shown.
11.In the same above window click”debugger” under category.Select “FET debugger &click
“ok” as shown
12.In the same above window click FET debugger under category.Select texas instrument USB –
IF under”conections”tab as shown.
13.Save the program &click on “Make” icon as shown.
14.Give the file name &save the window as shown

EMBEDDED SYSTEM LAB Page 4


15.Click the messages and it should be display the zero errors for proper error free program
compilation.
16.Click on download and debug icon
17.After downloading the program click ok on the stack warning messages.
18.Click go icon ->->-> as shown.
19.Observe the LED flashing(output varies for the corresponding experiments)in the MSP 430
kit.
PROGRAM:
#include "msp430x16x.h" ; Header file
;-------------------------------------------;
ORG 0E100h ; Program Start
;-------------------------------------------;
RESET mov.w #01500h,SP ; Initialize 'F161x stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT

;-------------------------------------------;
; Select & Stabilize XT2
;-------------------------------------------;
SetupBC bic.b #XT2OFF,&BCSCTL1 ; XT2 = on
SetupOsc bic.b #OFIFG,&IFG1 ; Clear OSC fault flag
mov.w #0FFh,R15 ; R15 = Delay
SetupOsc1 dec.w R15 ; Additional delay to ensure start
jnz SetupOsc1 ;
bit.b #OFIFG,&IFG1 ; OSC fault flag set?
jnz SetupOsc ; OSC Fault, clear flag again

bis.b #SELM1+SELS,&BCSCTL2 ; Drive SMCLK+MCLK from XT2 (safe)


;-------------------------------------------;
;Initialise Timer A
;-------------------------------------------;
SetupTA mov.w #TASSEL1+ID_3+TACLR,&TACTL ; SMCLK/8, clear TAR
SetupC0 mov.w #CCIE,&CCTL0 ; CCR0 interrupt enabled
mov.w #5000,&CCR0 ;

SetupP1 bis.b #008h,&P1DIR ; P1.3 output direction


bis.w #MC0,&TACTL ; Start Timer_a in upmode
eint ; Enable Global interrupt
;-------------------------------------------;

EMBEDDED SYSTEM LAB Page 5


Mainloop bis.w #CPUOFF,SR ; CPU off
nop ; Do nothing
jmp $ ; Self loop
;-------------------------------------------;
; Timer A CCR0 Interrupt service routine
;-------------------------------------------;
TA0_ISR xor.b #008h,&P1OUT ; Toggle P1.3
reti ;

;-------------------------------------------;
; Interrupt Vectors Used MSP430x161x
;-------------------------------------------;
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET ;

ORG 0FFECh ; Timer_A CCR0 Vector


DW TA0_ISR ;

END ; End of program


;-------------------------------------------;

RESULT:

Thus an ASM program to generate square wave for variable frequencies using MSP430
has been written and the output is verified.

EMBEDDED SYSTEM LAB Page 6


Experiment No: 3 INTERRUPT
Date:
AIM:
To write an ASM program to generate interrupt using MSP 430.

SOFTWARE REQUIRED:
IAR Software

HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 MSP430 KIT 1
2 Flash Emulation Tool 1
3 JTAG Cable 1
4 USB Cable 2

PROCEDURE:

1.Go to start- all programs- IAR systems--IAR embedded workbench.


2.Close the IAR information file
3.Create a project
4.Select the asm option and click ok
5.Enter the file name &save
6.Delete the basic asm file that is copied and it is shown in below
7.Write the program
8.Save the program.Click on the project name and right click on the project name. Click on
“options” tab.
9. Select general “options tab” under category.Select IC options under “device” tab.Click on the
correct MSP430 IC.
10.After selecting the correct IC click “ok” as shown.
11.In the same above window click”debugger” under category.Select “FET debugger &click
“ok” as shown
12.In the same above window click FET debugger under category.Select texas instrument USB –
IF under”conections”tab as shown.
13.Save the program &click on “Make” icon as shown.
EMBEDDED SYSTEM LAB Page 7
14.Give the file name &save the window as shown
15.Click the messages and it should be display the zero errors for proper error free program
compilation.
16.Click on download and debug icon
17.After downloading the program click ok on the stack warning messages.
18.Click go icon ->->-> as shown.
19.Observe the LED flashing(output varies for the corresponding experiments)in the MSP 430
kit.
PROGRAM:
#include "msp430x16x.h" ; Header file
;-------------------------------------------;
ORG 0E100h ; Progam Start
;-------------------------------------------;
RESET mov.w #01500h,SP ; Initialize 'F161x stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
;-------------------------------------------;
; Select & Stabilize XT2
;-------------------------------------------;
SetupBC bic.b #XT2OFF,&BCSCTL1 ; XT2on
SetupOsc bic.b #OFIFG,&IFG1 ; Clear OSC fault flag
mov.w #0FFh,R15 ; Give Delay
SetupOsc1 dec.w R15 ; Additional delay to ensure start
jnz SetupOsc1 ;
bit.b #OFIFG,&IFG1 ; OSC fault flag set?
jnz SetupOsc ; OSC Fault, clear flag again
bis.b #SELM1+SELS,BCSCTL2 ; MCLK = SMCLK = XT2 (safe)
;-------------------------------------------;
; Port Initialise
;-------------------------------------------;
Port1 mov.b #0F0h,&P1DIR ; P1.0-P1.3 as output
mov.b #00h,&P1OUT ; Clear Output Buffer
Port2 mov.b #00h,&P2OUT ;
mov.b #01Fh,&P2DIR ; Make P2.5-P2.7 as Input
bis.b #0E0h,&P2IES ; Edge Selection From High to Low
clr.b &P2IFG ; Clear pending Interrupts
bis.b #0E0h,&P2IE ; Enable Port Interrupt
eint ; Enable Global Interrupt
nop ; Do nothing

EMBEDDED SYSTEM LAB Page 8


bis.w #LPM4,SR ; Enter LPM4

;-------------------------------------------;
; Port2 Interrupt service routine
;-------------------------------------------;
PORT2_ISR call #DELAY_500ms ; Power on Delay
mov.b &P2IFG,&P1OUT ; Copy P2IFG value to glow LED
CALL #DELAY_500ms ; Delay
CLR.B &P1OUT ; Clear P1OUT
CLR.B &P2IFG ; Clear P2IFG
reti
;-------------------------------------------;
; Delay subroutine
;-------------------------------------------;

DELAY_16ms mov #0FFFFh,R12 ; Delay for 16ms


L3 dec R12
jnz L3
ret
;-------------------------------------------;
DELAY_500ms mov #01Eh,R11 ; Delay for 500 msec
L4 call #DELAY_16ms
dec R11
jnz L4
ret
;-------------------------------------------;
; Interrupt vector table for MSP430x161x
;-------------------------------------------;
ORG 0FFFEh ; Interrupt vector location for POWER ON RESET.
DW RESET
ORG 0FFE2h ; Port2 Interrupt Vector.
DW PORT2_ISR
END ; End of Program
;-------------------------------------------;

RESULT:

Thus an an ASM program to generate interrupt using MSP 430 has been written and the
output is verified.

EMBEDDED SYSTEM LAB Page 9


Experiment. No: 4 SERIAL COMMUNICATION
Date:

AIM:

To write an ASM program to transfer the data from MSP 430 to PC.

SOFTWARE REQUIRED:
 IAR Software

HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 MSP430 KIT 1
2 Flash Emulation Tool 1
3 JTAG Cable 1
4 USB Cable 2

PROCEDURE:
1. Go to start- all programs- IAR systems--IAR embedded workbench.
2. Close the IAR information file.
3. Create a project.
4. Select the asm option and click ok
5. Enter the file name &save
6. Delete the basic asm file that is copied and it is shown in below
7. Write the program
8. Save the program. Click on the project name and right click on the project name. Click on
“options” tab.
9. Select general “options tab” under category. Select IC options under “device” tab. Click on the
correct MSP430 IC.
10. After selecting the correct IC click “ok” as shown.
11. In the same above window click “debugger” under category. Select “FET debugger &click
“ok” as shown
12. In the same above window click FET debugger under category. Select Texas instrument USB
–IF under”conections”tab as shown.
13. save the program &click on “Make” icon as shown.

EMBEDDED SYSTEM LAB Page 10


14. Give the file name &save the window as shown
15. Click the messages and it should be display the zero errors for proper error free program
compilation.
16. Click on download and debug icon
17. After downloading the program click ok on the stack warning messages.
18. Click go icon ->->-> as shown.
19. Observe the LED flashing (output varies for the corresponding experiments)in the MSP 430
kit.
PROGRAM:
#include "msp430x16x.h" ; Header File
;-------------------------------------------;
ORG 0E100h ; Progam Start
;-------------------------------------------;
RESET mov.w #01500h,SP ; Initialize 'F161x stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
;-------------------------------------------;
; Select & Stabilize XT2
;-------------------------------------------;
SetupBC bic.b #XT2OFF,&BCSCTL1 ; XT2on
SetupOsc bic.b #OFIFG,&IFG1 ; Clear OSC fault flag
mov.w #0FFh,R15 ; Delay
SetupOsc1 dec.w R15 ; Additional delay to ensure start
jnz SetupOsc1 ;
bit.b #OFIFG,&IFG1 ; OSC fault flag set?
jnz SetupOsc ; OSC Fault, clear flag again

bis.b #SELM1+SELS,BCSCTL2 ; MCLK = SMCLK = XT2 (safe)


;-------------------------------------------;
; Initialise Port
;-------------------------------------------;
;-------------------------------------------;
; Initialise UART0
;-------------------------------------------;
SetupUART0 mov.b #CHAR,&UCTL0 ; 8-bit characters
mov.b #SSEL1,&UTCTL0 ; UCLK = SMCLK
mov.b #0A0h,&UBR00 ; 8Mhz/19200 ~ 417
mov.b #001h,&UBR10 ;
mov.b #000h,&UMCTL0 ; no modulation

EMBEDDED SYSTEM LAB Page 11


bis.b #UTXE0+URXE0,&ME1 ; Enable USART0 TXD/RXD
bis.b #URXIE0,&IE1 ; Enable USART0 RX interrupt
eint ; General enable interrupts
bis.b #030h,&P3SEL ; P3.4,P3.5 = USART0 TX,RX select
bis.b #010h,&P3DIR ; P3.4 = output direction
jmp $ ; Remain in loop
;-------------------------------------------;
; UART0 Receiver Interrupt service routine
;-------------------------------------------;
USART0_ISR bit.b #UTXIFG0,&IFG1 ; USART0 TX buffer ready?
jz USART0_ISR ; Jump is TX buffer not ready
mov.b RXBUF0,&TXBUF0 ; TX -> RXed character
reti ;
;-------------------------------------------;
; Interrupt Vectors Used MSP430x161x
;-------------------------------------------;
ORG 0FFFEh ;
DW RESET ; POR, ext. Reset, Watchdog
ORG 0FFF2h ;
DW USART0_ISR ; USART0 Receive
END ; End of program
;-------------------------------------------;

RESULT:

Thus an ASM program to transfer the data from MSP 430 to PC has been written and the
output is verified.

EMBEDDED SYSTEM LAB Page 12


Experiment No: 5 LED
Date :

AIM :
To write an Embedded C Program to Flash LED using 8051.
SOFTWARE REQUIRED :
 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

EMBEDDED SYSTEM LAB Page 13


PROGRAM:

#include <reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void _delay_ms(U32 ms);
void USART_Transmit(U8 tx_data);
U8 USART_Receive();
void uart_setup();
void main(void)
{
U8 rx_data;
uart_setup(); // calling the UART setup function
while(1)
{
rx_data= USART_Receive();
USART_Transmit(rx_data) ;
}
}
void uart_setup()
{
TMOD = 0x20; // configure timer1 for Mode 2 operation for the correct baud rate
TH1 = 0xFD; // 9600 bps for 11.0592 MHz clock
SCON = 0x50; // Set Serial IO to receive and normal mode
TR1=1;
}
unsigned char USART_Receive()
{
while(!RI);
RI = 0;
return SBUF ;
}
void USART_Transmit(U8 tx_data)
{
SBUF = tx_data;
while(!TI);
TI = 0;
}
RESULT:
Thus an Embedded C Program to Flash LED using 8051 has been written and the output is
verified.
Experiment No: 6 BUZZER
Date:
AIM :

EMBEDDED SYSTEM LAB Page 14


To write an Embedded C Program to make buzzer ON and OFF using 8051.

SOFTWARE REQUIRED :

 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

PROGRAM:
EMBEDDED SYSTEM LAB Page 15
#include<reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void _delay_ms(U32 ms);
sbit BUZZER = P2^0;
void main()
{
BUZZER = 1; // BUZZER on
_delay_ms(250); // delay 250 ms*/
BUZZER = 0; // BUZZER off
_delay_ms(250); // delay 250 ms
}
void _delay_ms(U32 ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1275;j++);
}

RESULT:
Thus an Embedded C Program to make LED ON and OFF using 8051 has been written
and the output is verified.
Experiment No: 7 SERIAL COMMUNICATION

Date :
AIM :
To write an Embedded C Program to transfer data from 8051 to Pc.

SOFTWARE REQUIRED :

EMBEDDED SYSTEM LAB Page 16


 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:
S.No Apparatus Required Quantity
1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

PROGRAM:
#include <reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void _delay_ms(U32 ms);
void USART_Transmit(U8 tx_data);

EMBEDDED SYSTEM LAB Page 17


U8 USART_Receive();
void uart_setup();
void main(void)
{
U8 rx_data;
uart_setup(); // calling the UART setup function
while(1)
{
rx_data= USART_Receive();
USART_Transmit(rx_data) ;
}
}
void uart_setup()
{
TMOD = 0x20; // configure timer1 for Mode 2 operation for the correct baud rate
TH1 = 0xFD; // 9600 bps for 11.0592 MHz clock
SCON = 0x50; // Set Serial IO to receive and normal mode
TR1=1;
}
unsigned char USART_Receive()
{
while(!RI);
RI = 0;
return SBUF ;
}
void USART_Transmit(U8 tx_data)
{
SBUF = tx_data;
while(!TI);
TI = 0;
}

RESULT:
Thus an Embedded C Program to transfer the data from 8051 to PC has been written and
the output is verified.

Experiment No: 8 LCD


Date :
AIM :
To write an Embedded C Program to display the words in LCD using 8051.

SOFTWARE REQUIRED :

EMBEDDED SYSTEM LAB Page 18


 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

PROGRAM:
#include<reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void _delay_ms(U32 ms);

EMBEDDED SYSTEM LAB Page 19


void lcd_init();
void lcd_cmd(U8 DATA);
void lcd_data(U8 DATA);
#define dataport P0 // Data port for LCD
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
void main()
{
lcd_init(); // Initialising LCD
lcd_data('E'); //" Displaying Embedded market "
lcd_data('M');
lcd_data('B');
lcd_data('E');
lcd_data('E');
lcd_data('D');
lcd_data('E');
lcd_data('D');
lcd_data('8');
lcd_data('0');
lcd_data('5');
lcd_data('1');
lcd_data('K');
lcd_data('I');
lcd_data('T');
while(1);
}
void lcd_cmd(U8 DATA) // Function to send command on LCD
{
dataport = DATA;
rs= 0; //rs = 0 for command
rw=0; // rw = 0 for writing a data to lcd buffer
en=1; // Enable High to low pulse for sending data to lcd
_delay_ms(1);
en=0;
return;
}
void lcd_data(U8 DATA) // Function to display character on LCD
{
dataport = DATA;
rs= 1; ////rs = 0 for data
rw=0; // rw = 0 for writing a data to lcd buffer
en=1; //// Enable High to low pulse for sending data to lcd
_delay_ms(1);
en=0;
return;
}
EMBEDDED SYSTEM LAB Page 20
void _delay_ms(U32 ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1275;j++);
}

void lcd_init()
{
lcd_cmd(0x38); // For using 8-bit 2 row LCD
_delay_ms(5);
lcd_cmd(0x0e); // For display on cursor blinking
_delay_ms(5);
lcd_cmd(0x01); // Clear display
_delay_ms(5);
lcd_cmd(0x06); // Increment the cursor
_delay_ms(5);
lcd_cmd(0x80); // Set the cursor on first position of
LCD
_delay_ms(5);
}

RESULT:
Thus an Embedded C Program to display the word in LCD using 8051 has been written and
the output is verified.

Experiment No: 9 DC MOTOR


Date :
AIM :
To write an Embedded C Program to rotate the DC Motor in clockwise and Anti-
clockwise direction using 8051.

SOFTWARE REQUIRED :
EMBEDDED SYSTEM LAB Page 21
 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

PROGRAM:
#include<reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void_delay_ms(U32ms);
EMBEDDED SYSTEM LAB Page 22
sbit I1=P2^0;
sbit I2=P2^1;
sbit I3=P2^2;
void main( )
{
EN=1;
While(1)
{
I1=1;
I2=0;
_delay_ms(500);
I1=1;
I2=1;
_delay_ms(500);
I1=0;
I2=1;
_delay_ms(500);
I1=1;
I2=1;
_delay_ms(500);
}
}
Void_delay_ms(U32ms);
{
Unsigned int i,j;
for(i=0;i<ms;i++)
for(j=0;j<ms;j++)
}

RESULT:
Thus an Embedded C Program to rotate the DC Motor in clockwise and Anti-clockwise
direction using 8051 has been written and the output is verified.

EMBEDDED SYSTEM LAB Page 23


Experiment No: 10 TIMER
Date :
AIM :
To write an Embedded C Program to generate square wave for variable frequencies using
8051.
SOFTWARE REQUIRED :
 Keil Microvision4.
 Flash Magic.

HARDWARE REQUIRED:
S.No Apparatus Required Quantity
1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.

EMBEDDED SYSTEM LAB Page 24


21. Select Hex file.
22. Enable verify after programming.

PROGRAM:
#include<reg51.h>
void T0Delay(void);
void main(void)
{
while(1)
{
P0=0x55;
T0Delay();
P0=0xAA;
T0Delay();
}
}
void T0Delay()
{
TMOD=0x01;
TL0=0x00;
TH0=0x35;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

RESULT:
Thus an Embedded C Program to generate square wave for variable frequencies using 8051
has been written and the output is verified.

EMBEDDED SYSTEM LAB Page 25


Experiment.No: 11 DESIGN OF FILTERS-FIR BASED
Date :
AIM:
To write a program of FIR filters using MATLAB.

SOFTWARE REQUIRED:
MATLAB R2009b
Personal computer

ALGORITHM:
1. Find the order and cutoff frequency of the Butterworth low pass filter
2. Find the transfer function of the Butterworth low pass filter
3. Find the frequency response of the corresponding filter
4. Plot the magnitude response for normalized frequency vs. gain
5. Plot the phase response for the normalized frequency vs. phase
6. Stop

PROGRAM:
clc;
clear all;
close all;
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*(wp/fs);
w2=2*(ws/fs);
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=choby1(n,rp,wn,'highpass');
w=0:0.01:pi;
[h,om]=freq(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);plot(om/pi,m);
EMBEDDED SYSTEM LAB Page 26
OUTPUT:

EMBEDDED SYSTEM LAB Page 27


xlabel('gain in dB--->');
ylabel('normalized frequency--->');
subplot(2,1,2);plot(om/pi,an);
ylabel('phase in radians');
xlabel('normalized frequency');

RESULT:
The MATLAB program for design of butter worth low pass digital filter has been verified.

EMBEDDED SYSTEM LAB Page 28


Experiment No: 12 DESIGN OF FILTERS-IIR BASED
Date :
AIM:
To write a program to IIR filters using MATLAB
SOFTWARE REQUIRED:
MATLAB R2009b.
Personal computer.
ALGORITHM:
1. Find the order and cutoff frequency of the Chebyshev - I high pass filter
2. Find the transfer function of the Chebyshev I high pass filter
3. Find the frequency response of the corresponding filter
4. Plot the magnitude response for normalized frequency vs. gain
5. Plot the phase response for the normalized frequency vs. phase
6. Stop

PROGRAM:
clc;
clear all;
close all;
format long;
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input ('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot (2,1,1);plot(om/pi,m);
ylabel('gain in db----->');
xlabel('normlized frequency---->');
subplot(2,1,2);plot(om.pi,an);
ylabel('phase in radians------>');
xlabel('normalized frequency---->');

EMBEDDED SYSTEM LAB Page 29


OUTPUT:

EMBEDDED SYSTEM LAB Page 30


RESULT:
The MATLAB program for design of Chebyshev type 1 high pass digital filter has been
verified

EMBEDDED SYSTEM LAB Page 31


Experiment No: 13 DESIGN AND IMPLEMENTATION OF SIMPLE
Date : COMBINATIONAL CIRCUITS
AIM:
To simulate and verify the functioning of half &full adder using verilog.
SOFTWARE REQUIRED:
 Modelsim
 PC
HALF ADDER
THEORY:
The half adder is a combinational circuit that accepts two inputs and produces two outputs
namely the sum and carry as per the truth table below.
OUTPUT
INPUT A INPUT B OUTPUT SUM
CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
We can see that the SUM is the XOR of the two inputs and CARRY is the AND of the two
inputs. The logic diagram of the half adder is shown.
LOGIC DIAGRAM:

VERILOG CODE FOR HALF ADDER:


Module halfadder(sum,carry,a,b);
Output sum,carry;
Input a,b;
Xor(sum,a,b);
And(carry,a,b);
Endmodule

EMBEDDED SYSTEM LAB Page 32


The full adder accepts two binary inputs and an input carry and generates a sum output and an
output carry. The truth table of a full adder is as shown.
INPUT A INPUT B INPUT C OUTPUT OUTPUT
SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
The K-map simplification gives the following equations for the sum output and carry output.

LOGIC DIAGRAM:

VERILOG CODE FOR FULL ADDER:


module fulladder(sum,cout,a,b,cin);
output sum,cout;
input a,b,cin;
xor(s1,a,b);
and(c1,a,b);
xor(sum,s1,cin);
and(c2,s1,cin);
or(cout,c1,c2)
endmodule

RESULT:
Thus the half adder and full adder has been simulated and verified using verilog coding.

EMBEDDED SYSTEM LAB Page 33


Experiment.No: 14 DESIGN AND IMPLEMENTATION OF SIMPLE SEQUENTIAL
CIRCUITS
Date:
AIM:
To simulate and verify the functioning of simple sequential circuits using verilog.
SOFTWARE REQUIRED:
Modelsim
PC
THEORY:
FLIP-FLOP

Flip-flop or latch is a circuit that has two stable states and can be used to store state information. A
flip-flop is a bistable multivibrator. The circuit can be made to change state by signals applied to one or
more control inputs and will have one or two outputs. It is the basic storage element in sequential logic.
Flip-flops and latches are a fundamental building block of digital electronics systems used in
computers, communications, and many other types of systems.
D-FLIP FLOP

The D flip-flop is widely used. It is also known as a "data" or "delay" flip-flop.The D flip-
flop captures the value of the D-input at a definite portion of the clock cycle (such as the rising
edge of the clock). That captured value becomes the Q output. At other times, the output Q
does not change.

TRUTH TABLE:

D Qn+1

0 0

1 1

VERILOG CODE FOR D FLIP FLOP :


module DFlipFlop(d, clk, clr, q, qbar);
input d;
input clk;
input clr;

EMBEDDED SYSTEM LAB Page 34


output q;
output qbar;
reg q;
assign qbar=~q;
always @(posedge clk)
if(~clr)q=0;
else q=d;
endmodule
SHIFT REGISTER
In digital circuits, a shift register is a cascade of flip flops, sharing the same clock, in
which the output of each flip-flop is connected to the "data" input of the next flip-flop in the
chain, resulting in a circuit that shifts by one position the "bit array" stored in it, shifting in the
data present at its input.
SISO:
In this case, the data bits are entered into the register serially and the output is also taken
serially.

PIPO:
In this case there is simultaneously entry of all data bits and the bits appear on parallel output
simultaneously.

SISO
module SISO(d,clk,rst,q);
input d,clk,rst;
output q;
wire w1,w2,w3;
dff1 a1(d,clk,rst,w1);
EMBEDDED SYSTEM LAB Page 35
dff1 a2(w1,clk,rst,w2);
dff1 a3(w2,clk,rst,w3);
dff1 a4(w3,clk,rst,q);
end module

PIPO
module PIPO(d,clk,rst,q);
input clk,rst;
input [3:0]d;
output [3:0]q;
dff1 a1(d[0],clk,rst,q[0]);
dff1 a2(d[1],clk,rst,q[1]);
dff1 a3(d[2],clk,rst,q[2]);
dff1 a4(d[3],clk,rst,q[3]);
end module

RESULT:

EMBEDDED SYSTEM LAB Page 36


Experiment .No : ADC
Date:
AIM :
To write an Embedded C Program to generate ADC using 8051.

SOFTWARE REQUIRED :

 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:
S.No Apparatus Required Quantity
1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.

EMBEDDED SYSTEM LAB Page 37


22. Enable verify after programming.

PROGRAM:
#include<reg51.h>
typedef unsigned char U8; // 8 bit
typedef unsigned int U32; // 32 bit
void _delay_ms(U32 ms);
void lcd_init();
void lcd_cmd(U8 DATA);
void lcd_data(U8 DATA);
void bcd_ascii(U8 i);
#define dataport P0 // Data port for LCD
#define adc_data P1 // Data port for ADC
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
void main()
{
U8 adc_data_aqu;
lcd_init(); // Initialising LCD
adc_data=0xff; // Making p1(adc_data) as input port
while(1)
{
adc_data_aqu=adc_data;
lcd_cmd(0x80);
lcd_data('A'); //" Displaying Embedded market "
lcd_data('D');
lcd_data('C');
lcd_data(' ');
lcd_data('D');
lcd_data('a');
lcd_data('t');
lcd_data('a');
lcd_data(' ');
bcd_ascii(adc_data_aqu);
}

void lcd_cmd(U8 DATA) // Function to send command on LCD

EMBEDDED SYSTEM LAB Page 38


{
dataport = DATA;
rs= 0; //rs = 0 for commamnd
rw=0; // rw = 0 for writting a data to lcd buffer
en=1; // Enable High to low pulse for sending data to lcd
_delay_ms(1);
en=0;
return;
}
void lcd_data(U8 DATA) // Function to display character on LCD
{
dataport = DATA;
rs= 1; ////rs = 0 for data
rw=0; // rw = 0 for writting a data to lcd buffer
en=1; //// Enable High to low pulse for sending data to lcd
_delay_ms(1);
en=0;
return;
}
void _delay_ms(U32 ms)
{
unsigned int i,j;
for(i=0;i<ms;i++)
for(j=0;j<1275;j++);
}
void lcd_init()
{
lcd_cmd(0x38); // For using 8-bit 2 row LCD
_delay_ms(5);
lcd_cmd(0x0e); // For display on cursor blinking
_delay_ms(5);
lcd_cmd(0x01); // For display on cursor blinking
_delay_ms(5);
lcd_cmd(0x06); // For display on cursor blinking
_delay_ms(5);
lcd_cmd(0x80); // Set the cursor on first position of LCD
_delay_ms(5);
}
void bcd_ascii(U8 i)
{
U8 x,y,z1,z2,z3;
EMBEDDED SYSTEM LAB Page 39
x=i/0X0a;
z1=i%0x0a;
z2=x%0x0a;
y=x/0x0a;
z3=y%0x0a;
z1=z1+0x30;
z2=z2+0x30;
z3=z3+0x30;
lcd_cmd(0xC2); //_ _ z1
lcd_data(z1);
lcd_cmd(0xC1); //_ z2 _
lcd_data(z2);
lcd_cmd(0xC0); //z3 _ _
lcd_data(z3);
}

RESULT
Thus an Embedded C Program to generate ADC using 8051 has been written and the output
is verified.
Experiment .No : SWITCH
Date:

EMBEDDED SYSTEM LAB Page 40


AIM :
To write an Embedded C Program of switch using 8051.

SOFTWARE REQUIRED :

 Keil Microvision4.
 Flash Magic.
HARDWARE REQUIRED:

S.No Apparatus Required Quantity


1 8051 Kit 1
2 USB-Emulator-8051 1
3 USB Cable 1
4 Power Adapter 1
5 Connecting Wires As required

PROCEDURE :
1. Create a folder in D Drive .
2. Select Keil Microvision4.
3. Select project select new Microvision4 project.
4. Select the folder which already created in create new project optionssave the file name.
5. Select device for Target ‘Target 1’ dialog box appearselect NXP Founded by Philips.
6. Select P89V51RD2.
7. Copy startup to project folder and add file to project dialog box appearselect yes.
8. File startup A51 already exists overwrite dialog box appear  select yes.
9. Then Target 1 will appear below project option select target 1 select new then text 1
screen will appear there type the program.
10. Save the program by selecting save options then save as dialog box will appear in that
select the folder already created in the save option.
11. Give the file name with the extension .c in the ‘filename option’.
12. maximize target 1, right click source group 1  ‘Add existing files’
13. Right click options for Target  Target 1 will appear.
14. Type the frequency 1100592 in  XTAL(MHZ) option.
15. Select  output OK.
16. Select Build.
17. SelectRebuild.
18. My computer right clickpropertiesHardwareDevice manager USB serial
port COM PORT.
19. FlashMagic P89V51RD2.
20. Enable erase all flash.
21. Select Hex file.
22. Enable verify after programming.

EMBEDDED SYSTEM LAB Page 41


PROGRAM:
#include<reg51.h>
typedef unsigned char U8; //8 bit
typedef unsigned int U32; // 32 bit
#define LED P0
sbit ps1 = P2^0;
sbit ps2 = P2^1;
sbit ps3 = P2^2;
sbit ps4 = P2^3;
void main()
{
ps1=1; // making port pin 2.0 as input pin
ps2=1; // making port pin 2.1 as input pin
ps3=1; // making port pin 2.2 as input pin
ps4=1; // making port pin 2.3 as input pin
while(1)
{
if(ps1 == 0)
LED=0xfe; // binary output 1
else if(ps2 == 0)
LED=0xfd; // binary output 2
else if(ps3 == 0)
LED=0xfc; // binary output 3
else if(ps4 == 0)
LED=0xfb; // binary output 4
}
}

EMBEDDED SYSTEM LAB Page 42


RESULT:
Thus an Embedded C Program of using 8051 has been written and the output is verified.

EMBEDDED SYSTEM LAB Page 43

Vous aimerez peut-être aussi