SlideShare a Scribd company logo
1 of 41
1
INTRODUCTION
DESCRIPTION OF EMBEDDED EVALUATION BOARD
1.1 INTRODUCTION
The Embedded Controller Evaluation Board provides the user with the features required to
understand the capabilities of an advanced microcontroller - the AT89C51ED2 Micro controller.
The AT89C51ED2 is architecturally compatible with the Intel 89C51. The board consists of
 The Flash programmable AT89C51ED2 controller
 8 numbers of LED’s
8 numbers of Switches
 16 X 2 Line LCD Alphanumeric Display
 RS232C compatible Serial Interface for communication , ISP
 SPI compatible 12 bit ADC with Temperature Sensor Interface
 4 numbers of multiplexed 7- Segment Displays
 I2C 8-bit ADC/DAC Interface
 I2C RTC
 I2C NVROM
 4 numbers of high Current Output lines
 One changeover Relay for Experiments
 In System Programming capability
1.2 SPECIFICATIONS
The Flash Programmable Embedded Controller Evaluation Board consists of
 The Atmel 89C51ED2- 8-bit micro controller (U1) with operating frequency of
11.0592MHz with an external crystal and supply voltage of 5V. It has 64K bytes of flash
memory block for program and data and 1792 bytes of XRAM
 A 26 pin FRC connector CN3 connected to Ports 0,1 and 2 of the controller, which is
compatible with ALS standard external interfaces.
 26 pin FRC connector CN4 which can be connected to Port 0,1 and 2 Lines to study the
internal features of the controller , Reading Switches, PWM, ADC, DAC, RTC,
NVROM, 7-segment Displays etc.
 A 9 pin D-type female connector CN2, RS232 serial i/o interface for UART experiments
and flash programming.
 A 9 pin D-type male Connector CN1 for power connection (+5V and GND).
 Push buttons switch SW2 for Reset and a Slide switch SW1 to select either program
mode or run mode.
2
 Push buttons switch SW3 for External Interrupt INT0.
 Eight numbers of LED's (L3 to L10) interfaced through serial shift register
 Eight key switches (SW4 to SW11) organized in 2 rows X 4 columns
 8bit ADC / DAC using I2C device (U17)
 NVROM 24C16 – I2C compatible (U7)
 RTC - DS1307 - I2C compatible (U6)
 Four numbers CC seven segment multiplexed displays (U12,U13,U14,U15)
 One DPDT relay with contact terminated in relaimate (RLY1)
 Four High Current Output (300 ma) using ULN2803 (U16)
 One SPI ADC (MCP3202) with Temperature Sensor IC LM335 (U4)
 Elegant enclosure with Test Points for monitoring (TPs)
1.3 BLOCK DIAGRAM
3
1.4: APPLYING POWER
Connect a 9-pin D-type(DB) Female Connector to a 9-pin DB Male connector CN1
provided on the Embedded Controller Evaluation Board (ALS-EMB-EVAL-02).
The color code for the supply is
Pin No Voltages Color Code(Female)
9 VCC(+5) Orange/White/Blue
4,5 GND Yellow/Black
As soon as the power is applied the sign on message “EMBEDDED CONTROLLER
EVALUATION BOARD” appears on the LCD. If the sign on message will not appear check
the slide switch SW1 is in RUN position on the board and +5V is present at the corresponding
VCC inputs of the IC pins. (Ex. Pin-44 of AT89C51ED2). If not switch off the power supply and
verify that the IC's on the trainer are mounted properly or not. Press all the IC's tightly into their
bases, switch on again and if sign on message still doesn't appears, refer to the factory.
1.5: SERIAL COMMUNICATION OPERATION
To connect Embedded Controller Evaluation Board (ALS-EMB-EVAL-02) to host
computer system the procedure is as follows - Connect one end of the 9-pin RS232 cross cable
(Female Type) to the host computer system and other end (Male Type) to the serial port
connector
CN2 on the ALS-EMB-EVAL-02 board.
Set the host computer system baud rate, data length and parity bit. The default values are
9600 baud, 1 stop bit and none parity bit. This setting is done in Device Manager explorer of the
computer system.
RS232 Cable Connection
ALS-EMB-EVAL-02
Pin No(9 Pin Male DB)
Host Computer
Pin No (9 Pin Female DB)
2 (RXD) 2 (RXD)
3 (TXD) 3 (TXD)
5 (Signal GND) 5 (Signal GND)
4
EXPERIMENT NO: 01
LED BLINKING
AIM: To write a program for the LEDs blinking.
APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip
HARDWARE: Embedded control evaluation board, PC
PROGRAM:
#include<at89c51xd2.h>
#include<intrins.h>
unsigned char ref_byte = 0xFF,temp,count =0x00;
void DelayMs(unsigned int);
void led_init(void);
sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5 (Serial In Parralel Out)
sbit LED = P2^7; //Data Line of the 8-bit shift reg U5
main()
{
AUXR = 0x10; //Accesiing Full XRAM
CLKL = 0;
led_init(); //Clearing ALL LEDs FROM L3 TO L10
DelayMs(1000);
while(1)
{
temp = ref_byte;
LED = (temp & 0x80)? 0:1;
CLKL = 1;
DelayMs(1);
CLKL = 0;
ref_byte <<= 1;
count++;
if(count == 0x08)
{
count = 0x00;
ref_byte = 0x01;
}
DelayMs(1000);
}
}
void DelayMs(unsigned int count)
{ // mSec Delay 11.0592 Mhz
unsigned int i;
while(count)
5
{
i = 110;
while(i>0) i--;
count--;
}
}
// To clear All LEDs
void led_init(void)
{
unsigned int j;
CLKL = 0;
LED = 1;
for(j=0;j<8;j++)
{
CLKL = 1;
_nop_();
_nop_();
CLKL =0;
_nop_();
}
}
OUTPUT: The LED blinking is being observed from L3 to L10 on the target board.
RESULT: Thus the LED blinking program is being compiled, debugged and executed successfully.
6
EXPERIMENT NO: 02
PROGRAM ON TIMERS
AIM: To write a program for DELAY using TIMER-0 and switch on a LED in timer subroutine.
APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip
HARDWARE: Embedded control evaluation board, PC
PROGRAM:
#include <at89c51xd2.h>
#include <intrins.h> //For _nop_();
void led_init(void);
void timer0_init(void);
sbit L = P1^5; //LED L2 Operation
sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5(Serial In parrale Out)
sbit LED = P2^7; //Data Line of the 8-bit shift reg U5
void main(void)
{
AUXR = 0x10; // Accesiing Ful XRAM
led_init(); //CLearing All LEDs from L3 to L10
timer0_init();
EA = 1; //Enabling Global Interrupt
while(1);
}
void timer0_init(void)
{
TMOD = 0x01; //Timer0 in Mode1,
TL0 = 0xff;
TH0 = 0x6f; //For 40ms Delay
TCON = 0x00; //TF0 = 0; //Clearing All Flags
ET0 = 1; //Enabling Timer0 Interrupt
TR0 = 1; //Starting Timer0
}
void timer0_isr(void) interrupt 1
{
L = ~L; //Toggling LED L2
7
TF0 = 0; //Clearing Interrupt Flag
TL0 = 0xff;
TH0 = 0x6f; //Reloading Value into registers for every overflow
}
// To clear All LEDs L3 to L10
void led_init(void)
{
unsigned int j;
CLKL = 0;
LED = 1;
for(j=0;j<8;j++)
{
CLKL = 1;
_nop_();
_nop_();
CLKL =0;
_nop_();
}
}
OUTPUT: It is being observed that the routine delay of 40ms has been done. In ISR of timer0, LED
L2 that is connected to port line P1.5 is being toggled for every 40ms.
RESULT: Thus the program is being compiled, debugged and executed successfully.
8
EXPERIMENT NO: 03
LCD INTERFACE
AIM: To write a program for LCD testing. .
APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip
HARDWARE: Embedded control evaluation board, PC
PROGRAM:
#include<at89c51xd2.h>
#include<intrins.h>
// LCD FUNCTION PROTOTYPE
void lcd_init(void);
void lcd_comm(void);
void wr_cn(void);
void lcd_data(void);
void wr_dn(void);
void clear_lcd(void);
void maxdelay(void);
void mindelay(void);
unsigned int i=0;
unsigned char temp1=0x00,var=0x00;
unsigned char temp2;
void led_init(void);
unsigned char arr[32] = " EMBEDDED SYSTEMS AND VLSI ";
sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5 (Serial In Parralel Out)
sbit LED = P2^7; //Data Line of the 8-bit shift reg U5
void main(void)
{
AUXR = 0x10; // Accesiing Ful XRAM
led_init(); //CLearing All LEDs from L3 to L10
lcd_init(); // Initialize the LCD
clear_lcd();
temp1 = 0x80;
lcd_comm(); // Displaying at 1st line of LCD
for(i=0;i<32;i++)
{
if(i == 16)
{
9
temp1 = 0xc0;
lcd_comm(); // Displaying at 2nd line of LCD
}
temp2 = arr[i];
lcd_data();
}
while(1);
}
void lcd_init(void)
{
temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1
wr_cn();
maxdelay();
temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1
wr_cn();
maxdelay();
temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1
wr_cn();
maxdelay();
temp1 = 0x08; // D5(P3.3)=1
wr_cn();
maxdelay();
temp1 = 0x28;
lcd_comm();
maxdelay();
temp1 = 0x0f; //display on,cursor on
lcd_comm();
maxdelay();
temp1 = 0x06; //shift cursor right with auto increment
lcd_comm();
maxdelay();
temp1 = 0x80; //clear display with cursor on first position
lcd_comm();
maxdelay();
}
// Function to pass commands to LCD
void lcd_comm(void)
{
var = temp1;
temp1 = temp1 & 0xf0;
10
temp1 = temp1 >> 2;
wr_cn();
temp1 = var & 0x0f;
temp1 = temp1 << 2;
wr_cn();
mindelay();
}
// Function to pass data to LCD
void lcd_data(void)
{
var = temp2;
temp2 = temp2 & 0xf0; // convert the byte into nibble
temp2 = temp2 >> 2;
wr_dn();
temp2 = var & 0x0f;
temp2 = temp2 << 2;
wr_dn();
mindelay();
}
// Function to write to command reg of LCD
void wr_cn(void)
{
temp1 = temp1 & 0x7f; // RS(P3^7)=0
temp1 = temp1 | 0x43; // EN(P3^6)=1, TXD(P3^1)=1, RXD(P3^0)=1
P3 = temp1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
temp1 = temp1 & 0xbf; // EN(P3^6)=0,
P3 = temp1;
}
// Function to write to data reg of LCD
void wr_dn(void)
{
temp2 = temp2 | 0xc3; // RS(P3^7)=1,EN=1,TXD=1,RXD=1
P3 = temp2;
11
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
temp2 = temp2 & 0xbf; // EN = 0
P3 = temp2;
}
// Function to clear the LCD display
void clear_lcd()
{
temp1 = 0x01;
lcd_comm();
maxdelay();
}
void maxdelay(void)
{
int i,j;
/* for(i=0;i<5;i++)
for(j=0;j<50;j++); //2.1ms Delay*/
for(i=0;i<10;i++)
for(j=0;j<50;j++); //4.1ms Delay*/
}
void mindelay(void)
{
int j;
for(j=0;j<60;j++); //0.52ms Delay
}
// To clear All LEDs L3 to L10
void led_init(void)
{
unsigned int j;
CLKL = 0;
LED = 1;
for(j=0;j<8;j++)
{
CLKL = 1;
_nop_();
_nop_();
CLKL =0;
_nop_();
}
12
}
OUTPUT: “EMBEDDED SYSTEMS AND VLSI” is being observed on the LCD screen.
RESULT: Thus the LCD TEST program is being compiled, debugged and executed successfully.
13
EXPERIMENT NO: 04
KEYPAD INTERFACE
AIM: To write the program to interface keypad to 8051.
APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Atmel Flip
HARDWARE REQUIREMENTS: Embedded control evaluation board, PC
PROGRAM:
#include<at89c51xd2.h>
#include<intrins.h>
/*key_arr :-->
0x8E -> ROW2 SW8 0x1E -> ROW1 SW4
0x8D -> ROW2 SW9 0x1D -> ROW1 SW5
0x8B -> ROW2 SW10 0x1B -> ROW1 SW6
0x87 -> ROW2 SW11 0x17 -> ROW1 SW7
0x8E,0x8D,0x8B,0x87 -> 8(1000) is for ROW2(P2.4*)=0;ROW1(P1.7*)=1
0x1E,0x1D,0x1B,0x17 -> 1(0001) is for ROW1(P1.7*)=0;ROW2(P2.4*)=1
E -> 1110 -> for P2.0* SW4 & SW8
D -> 1101 -> for P2.1* SW5 & SW9
D -> 1011 -> for P2.2* SW6 & SW10
D -> 0111 -> for P2.3* SW7 & SW11 */
unsigned char key_arr[8] = {0x8E,0x8D,0x8B,0x87,0x1E,0x1D,0x1B,0x17};
/*array_dec[10]:->
value= h g f e d c b a On 7-SEG U15
0x66 = 0 1 1 0 0 1 1 0 -> Displaying '4'
0x6D = 0 1 1 0 1 1 0 1 -> Displaying '5'
0x7D = 0 1 1 1 1 1 0 1 -> Displaying '6'
0x07 = 0 0 0 0 0 1 1 1 -> Displaying '7'
0x3F = 0 0 1 1 1 1 1 1 -> Displaying '0'
0x06 = 0 0 0 0 0 1 1 0 -> Displaying '1'
0x5B = 0 1 0 1 1 0 1 1 -> Displaying '2'
0x4F = 0 1 0 0 1 1 1 1 -> Displaying '3'
0x7F = 0 1 1 1 1 1 1 1 -> Displaying '8'
0x6F = 0 1 1 0 1 1 1 1 -> Displaying '9' */
unsigned char array_dec[10] = {0x66,0x6D,0x7D,0x07,0x3F,0x06,0x5B,0x4F,0x7F,0x6F};
unsigned char key_rtn=0x00,key_flag=0x00,temp =0x00,temp2 = 0x00;
unsigned char row = 0xEF,temp_row = 0x00,key = 0x00,tmp_rw1=0x00,tmp_rw2=0x00;
unsigned int i = 0;
void key_press(void);
void scan(void);
void DelayMs(unsigned int);
void Display(void);
void led_init(void);
14
sbit EN = P1^2; //Latch Enable Line of second 2to4 LineDecoder of U8
//U8 is having two 2to4 line decoders
sbit SEL0 = P1^3; //Data Latch 1A of the 1st decoder of U8
sbit SEL1 = P1^5; //Data Latch 1B of the 1st decoder of U8
sbit ENL = P2^5; //Data Latch 2B of the 2nd decoder of U8
sbit ROW2 = P2^4; //Second row of thw 2X4 keypad
sbit ROW1 = P1^7; //First row of thw 2X4 keypad
sbit CS = P1^4; //Chip select line for SPI device U3
sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5(Serial In parrale Out)
sbit LED = P2^7; //Data Line of the 8-bit shift reg U5
void main()
{
AUXR = 0x10;//Accessing Ful XRAM
led_init(); //For Clearing All LEDs L3 to L10
P2 = 0xFF; //make Port 2 high;
P1 = 0xFF; //make Port 1 high;
P0 = 0x00; //port for 7-seg data
EN = 1; //Disabling 2nd Decoder
ENL = 0; //Data Latch Enable line
CS = 1; //to disable SPI
while(1)
{
ROW1 = 0; //fOR ROW1 (SW4 TO SW 7)
ROW2 = 1;
key_press();
if(key_flag == 0xFF)//If key Pressed
{
scan();
Display(); //Displying the num on the 7-Seg U15
}
ROW1 = 1; //fOR ROW2 (SW8 TO SW 11)
ROW2 = 0;
key_press();
if(key_flag == 0xFF)//If key Pressed
{
scan();
Display(); //Displying the num on the 7-Seg U15
}
} //end of while(1) loop
}
/* Key_press() function is used to check which portline has gone
LO Initialy the portlines P2.0*,P2.1*,P2.2*,P2.3* are HI, so when
pressing SWitches the perticular portline goes LO (Such that LO
at P1.7* will go to the perticular portline P2.0* to P2.3*).
P1.7* and P2.4* are Outpuit Lines
P2.7* to P2.3* are input lines to Contrller */
15
void key_press(void)
{
temp = P2 & 0x0F; //Read the keys(Masking the Lowr Nibble)
DelayMs(1); //wait for debounce
temp = P2 & 0x0F; //Again Read the keys(Masking the Lowr Nibble)
DelayMs(1); //wait for debounce
if(temp == 0x0F) //If No key has been pressed
key_flag = 0x00;
else
{
key_flag = 0xFF;//If Key pressed
DelayMs(1); //wait for debounce
while(temp == (temp2 = P2 & 0x0F));//waiting for key lift
key_rtn = temp; //taking the value read 'temp' wen pressing key
//i.e. P2=0x0F (Initialy P2.0 to P2.3 are at HI)
//P2=0x0E wen SW4 0r SW8 are pressed depending upon ROW1&ROW2
//P2=0x0D wen SW5 0r SW9 are pressed depending upon ROW1&ROW2
//P2=0x0B wen SW6 0r SW10 are pressed depending upon ROW1&ROW2
//P2=0x07 wen SW7 0r SW11 are pressed depending upon ROW1&ROW2
}
}
/* scan() function is used for masking perticular ROW line and
getting it in one variable,after this combining the masked ROW
line with the COL lines... The reult carible is being compared
with the Lookup Table key_arr[] and getting the corresponding
index of the Display array array_dec[]
For Ex:
For key_arr[i=0] = 0x8E; key = i = 0 array_dec[key] = 0x66 '4'
For key_arr[i=3] = 0x87; key = i = 3 array_dec[key] = 0x07 '7'
For key_arr{i=4] = 0x1E; key = i = 4 array_dec[key] = 0x3F '0'
For key_arr{i=6] = 0x1B; key = i = 6 array_dec[key] = 0x5B '2' */
void scan(void)
{
tmp_rw1 = P1 & 0x80; //Masking P1.7* portline
tmp_rw2 = tmp_rw1 | (P2 & 0x10);//Masking P2.4* portline
tmp_rw2 = tmp_rw2 & 0x90; //Again Masking P1.7* & P2.4*
key_rtn = key_rtn | tmp_rw2; //Combining ROWs(P1.7*&P2.4*)//and COLs(P2.0* to
P2.3*)
for(i=0;i<8;i++)
if(key_rtn == key_arr[i])
key = i; //Getting the correspondin index value for
//displaying 0,1,2,3,4,5,6,7 on U15
}
/*Portlines P0.0* to P0.7* are given to the 7 segment displays
thru Buffer
16
P0.0* to P0.7* ===> a,b,c,d,e,f,g,h segments respectivly */
void Display(void)
{
P0 = array_dec[key];//Decoding the key value to that of 7-segment
ENL = 0;
SEL1 = 1; //Select lines for segments
SEL0 = 1; //00 for U12,01 for U13
//10 for U14,11 for U15
EN = 0;
DelayMs(2);
EN = 1;
}
void DelayMs(unsigned int count)
{ // 0.1 mSec Delay 11.0592 Mhz
unsigned int i;
while(count)
{
i = 11;
while(i>0) i--;
count--;
}
}
// To clear All LEDs
void led_init(void)
{
unsigned int j;
CLKL = 0;
LED = 1;
for(j=0;j<8;j++)
{
CLKL = 1;
_nop_();
_nop_();
CLKL =0;
_nop_();
}
}
OUTPUT: It is being observed that key numbers 0 to 7 for switches SW4 to SW11 respectively
displayed on the right most 7-segment display U15.
RESULT: Thus the keypad program is being compiled, debugged and executed successfully.
17
EXPERIMENT NO: 05
KEYPAD INTERFACE
AIM: To write the program to interface LCD to ARM7(LPC2148) microcontroller.
APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic
HARDWARE REQUIREMENTS: LPC2148 development board, PC
PROGRAM:
main.c file
#include "lcd.h"
int main (void)
{
init_lcd();
while (1)
{
lcd_data_write('a');
}
}
lcd.c file
#include <LPC214x.H> /* LPC214x definitions */
#include "lcd.h"
#define LCD_BACK_LIGHT_TIMEOUT 1000
#define LCD_BACKLIGHT (1 << 21)
#define LCD_BACK_LIGHT_DIR IO1DIR
#define LCD_BACK_LIGHT_SET IO1SET
#define LCD_BACK_LIGHT_CLR IO1CLR
#define LCD_DATA_DIR IO0DIR
#define LCD_DATA_SET IO0SET
#define LCD_DATA_CLR IO0CLR
#define LCD_CTRL_DIR IO1DIR
#define LCD_CTRL_SET IO1SET
#define LCD_CTRL_CLR IO1CLR
#define LCDRS (1 << 24)
#define LCDRW (1 << 23)
#define LCDEN (1 << 22)
18
#define LCD_D4 (1 << 10)
#define LCD_D5 (1 << 11)
#define LCD_D6 (1 << 12)
#define LCD_D7 (1 << 13)
#define LCD_DATA_MASK (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)
#define LCD_BUSY_FLAG LCD_D7
#define LCD_CONTROL_MASK 0x01C00000
/**
**************************************************************************
****1111
Function Name : delay()
Description :This function suspends the tasks for specified ticks.
Input : ticks:no of ticks in multiple of 1 usec
task: task to be suspended
Output : void
Note :
*******************************************************************************
*/
void delay(int count)
{
int j=0,i=0;
for(j=0;j<count;j++)
{
/* At 60Mhz, the below loop introduces
delay of 10 us */
for(i=0;i<35;i++);
}
}
/**
*********************************************************************************
***********
Function Name : wait_lcd()
Description :
Input :
19
Output : Void
Note :
*********************************************************************************
***********
*/
void wait_lcd( void )
{
LCD_CTRL_CLR |= LCDRS;
LCD_CTRL_SET |= LCDRW |LCDEN;
while(IO1PIN & LCD_BUSY_FLAG); /* wait for busy flag to become low */
LCD_CTRL_CLR |= LCDEN | LCDRW;
LCD_DATA_DIR |= LCD_DATA_MASK;
delay(100);
}
/**
*********************************************************************************
***********
Function Name : lcd_command_write()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void lcd_command_write( unsigned char command )
{
unsigned char temp=0;
unsigned int temp1=0;
temp=command;
temp=(temp>>4)&0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;
LCD_CTRL_CLR = LCDRS;
LCD_CTRL_SET = LCDEN;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
delay(10000);
20
LCD_CTRL_CLR = LCDEN;
temp=command;
temp&=0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;
delay(100*2);
LCD_CTRL_CLR |= LCDRS;
LCD_CTRL_SET |= LCDEN;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
delay(10000);
LCD_CTRL_CLR |= LCDEN;
wait_lcd();
}
/**
*********************************************************************************
***********
Function Name : set_lcd_port_output()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void set_lcd_port_output( void )
{
LCD_CTRL_DIR |= ( LCDEN | LCDRS | LCDRW );
LCD_CTRL_CLR |= ( LCDEN | LCDRS | LCDRW );
LCD_DATA_DIR |= LCD_DATA_MASK;
}
/* *
*********************************************************************************
***********
Function Name : lcd_clear()
Description :
Input :
Output : Void
21
Note :
*********************************************************************************
***********
*/
void lcd_clear( void)
{
lcd_command_write( 0x01 );
}
/**
*********************************************************************************
***********
Function Name : lcd_gotoxy()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
int lcd_gotoxy( unsigned int x, unsigned int y)
{
int retval = 0;
if( (x > 1) && (y > 15) )
{
retval = -1;
} else {
if( x == 0 )
{
lcd_command_write( 0x80 + y ); /* command - position cursor at 0x00 (0x80 + 0x00 )
*/
} else if( x==1 ){
lcd_command_write( 0xC0 + y ); /* command - position cursor at 0x40 (0x80 + 0x00 )
*/
}
}
return retval;
}
/**
*********************************************************************************
***********
Function Name : lcd_data_write()
22
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void lcd_data_write( unsigned char data )
{
unsigned char temp=0;
unsigned int temp1=0;
temp=data;
temp=(temp>>4)&0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;
LCD_CTRL_SET |= LCDEN|LCDRS;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
LCD_CTRL_CLR |= LCDEN;
temp=data;
temp&=0x0F;
temp1=(temp<<10)&LCD_DATA_MASK;
LCD_CTRL_SET |= LCDEN|LCDRS;
LCD_DATA_CLR = LCD_DATA_MASK;
LCD_DATA_SET = temp1;
LCD_CTRL_CLR |= LCDEN;
wait_lcd();
}
/**
*********************************************************************************
***********
Function Name : lcd_putchar()
Description :
Input :
Output : Void
Note :
23
*********************************************************************************
***********
*/
void lcd_putchar( int c )
{
lcd_data_write( c );
}
/**
*********************************************************************************
***********
Function Name : lcd_putstring()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void lcd_putstring( unsigned char line, char *string )
{
unsigned char len = MAX_CHAR_IN_ONE_LINE;
lcd_gotoxy( line, 0 );
while(*string != '0' && len--)
{
lcd_putchar( *string );
string++;
}
}
/**
*********************************************************************************
***********
Function Name : lcd_backlight_on()
Description :
Input :
Output : Void
Note :
24
*********************************************************************************
***********
*/
void lcd_backlight_on()
{
LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT;
LCD_BACK_LIGHT_SET |= LCD_BACKLIGHT;
}
/**
*********************************************************************************
***********
Function Name : turn_off_lcd_back_light()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void turn_off_lcd_back_light_cb(void)
{
LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT;
LCD_BACK_LIGHT_CLR |= LCD_BACKLIGHT;
}
/**
*********************************************************************************
***********
Function Name : init_lcd()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void init_lcd( void )
{
25
set_lcd_port_output();
delay(100*100);
lcd_command_write(0x28); /* 4-bit interface, two line, 5X7 dots. */
lcd_clear() ; /* LCD clear */
lcd_command_write(0x02); /* cursor home */
lcd_command_write(0x06); /* cursor move direction */
lcd_command_write(0x0C) ; /* display on */
lcd_gotoxy(0, 0);
lcd_clear();
lcd_putstring(0," N G X ");
lcd_putstring(1," TECHNOLOGIES ");
}
#ifndef _LCD_H
#define _LCD_H
#define MAX_CHAR_IN_ONE_LINE 16
enum ROW_NUMBERS
{
LINE1,
LINE2
};
void init_lcd(void);
void lcd_putstring(unsigned char line, char *string);
void lcd_clear(void);
void lcd_backlight_on(void);
int lcd_gotoxy(unsigned int x, unsigned int y);
void lcd_putchar(int c);
#endif
Result:
26
EXPERIMENT NO: 06
EXTERNAL INTERRUPT HANDLER
AIM: To write the program for external interrupt handler for ARM7(LPC2148) and turn on buzzer
on interrupt.
APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic
HARDWARE REQUIREMENTS: LPC2148 development board, PC
PROGRAM:
Main.c file
#include <LPC214x.H> /* LPC21xx definitions */
#include "ext_int.h"
int main (void)
{
init_ext_interrupt(); // initialize the external interrup
while (1)
{
}
}
Ext_int.h
#ifndef _KEYPAD_H
#define _KEYPAD_H
#include <LPC214x.H> /* LPC21xx definitions */
#define KEY_NOT_PRESSED 0xFF
#define KEYPAD_DATA_DIR IODIR1
#define KEYPAD_DATA IOPIN1
#define KEYPAD_COL_SET IOSET1
#define KEYPAD_ROW_SET IOSET1
#define KEYPAD_COL_CLR IOCLR1
#define KEYPAD_ROW_CLR IOCLR1
#define COL_MASK (COL0 | COL1 | COL2 | COL3)
#define ROW_MASK (ROW0 | ROW1 | ROW2 | ROW3)
#define COL0 (1 << 21)
#define COL1 (1 << 22)
#define COL2 (1 << 23)
#define COL3 (1 << 24)
27
#define ROW0 (1 << 17)
#define ROW1 (1 << 18)
#define ROW2 (1 << 19)
#define ROW3 (1 << 20)
void init_ext_interrupt(void);
unsigned char key_hit(unsigned char **key);
void Ext_ISR(void) __irq;
unsigned char read_key(void);
#endif
Ext_int.c file
#include <LPC214x.H> /* LPC21xx definitions */
#include "Ext_Int.h"
#include "buzzer.h"
#define EXTINT_EINT2_MASK 0x4
#define EXTMODE_EXTMODE2_MASK 0x4
#define EXTPOLAR_EXTPOLAR2_MASK 0x4
// Vector Control Register bit definitions
#define VIC_ENABLE (1 << 5)
// Convert Channel Number to Bit Value
#define VIC_BIT(chan) (1 << (chan))
#define VIC_EINT2 16
/**
**************************************************************************
****1111
Function Name : delay()
Description :This function suspends the tasks for specified ticks.
Input : ticks:no of ticks in multiple of 1 usec
task: task to be suspended
Output : void
Note :
*******************************************************************************
*/
28
void delay(int count)
{
int j=0,i=0;
for(j=0;j<count;j++)
{
/* At 60Mhz, the below loop introduces
delay of 10 us */
for(i=0;i<35;i++);
}
}
/**
*********************************************************************************
***********
Function Name : key_init()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void init_ext_interrupt()
{
EXTMODE = EXTMODE_EXTMODE2_MASK;
EXTPOLAR &= ~EXTPOLAR_EXTPOLAR2_MASK;
PINSEL0 = (PINSEL0 & ~(3U << 30)) | (1U << 31);
/* initialize the interrupt vector */
VICIntSelect &= ~ VIC_BIT(VIC_EINT2); // EINT0 selected as IRQ
VICVectAddr5 = (unsigned int)Ext_ISR; // address of the ISR
VICVectCntl5 = VIC_ENABLE | VIC_EINT2;
VICIntEnable = VIC_BIT(VIC_EINT2); // EINT0 interrupt enabled
EXTINT &= ~EXTINT_EINT2_MASK;
}
/**
*********************************************************************************
***********
29
Function Name : keypad_ISR()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void Ext_ISR(void) __irq
{
turn_on_buzzer();
delay(10000);
turn_off_buzzer();
EXTINT |= EXTINT_EINT2_MASK; //clear interrupt
VICVectAddr = 0;
}
Buzzer.h file
#ifndef _BUZZER_H
#define _BUZZER_H
void turn_on_buzzer(void);
void turn_off_buzzer(void);
#endif // _BUZZER_H
Buzzer.c file
#include <LPC214x.H> /* LPC21xx definitions */
#define BUZZER (1 << 25)
#define BUZZER_DIR IO1DIR
#define BUZZER_SET IO1SET
#define BUZZER_CLR IO1CLR
/**
*********************************************************************************
***********
Function Name : turn_on_buzzer()
30
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void turn_on_buzzer()
{
BUZZER_DIR |= BUZZER;
BUZZER_CLR |= BUZZER;
}
/**
*********************************************************************************
***********
Function Name : turn_off_lcd_back_light()
Description :
Input :
Output : Void
Note :
*********************************************************************************
***********
*/
void turn_off_buzzer(void)
{
BUZZER_DIR |= BUZZER;
BUZZER_SET |= BUZZER;
}
31
EXPERIMENT NO: 07
ANALOG TO DIGITAL CONVERSION
AIM: To write the program for analog to digital conversion and and display the digital value on
LCD.
APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic
HARDWARE REQUIREMENTS: LPC2148 development board, PC
PROGRAM:
Main.c file
#include <stdio.h>
#include <LPC214x.H> /* LPC214x definitions */
#include "lcd.h"
#include "adc.h"
/**
**************************************************************************
****1111
Function Name : wait()
Description :This function suspends the tasks for specified ticks.
Input : ticks:no of ticks in multiple of 1 usec
task: task to be suspended
Output : void
Note :
*******************************************************************************
*/
void wait(int count)
{
int j=0,i=0;
for(j=0;j<count;j++)
{
/* At 60Mhz, the below loop introduces
delay of 10 us */
for(i=0;i<35;i++);
}
}
/**
32
*********************************************************************************
***********
Function Name : process_adc()
Description :
Input : Void
Output : Void
Note :
*********************************************************************************
*************
*/
void process_adc(void)
{
unsigned short adc_value = 0;
unsigned char buf[16] = {0};
adc_value = adc_read(ADC0, CHANNEL_3);
sprintf((char *)buf, "ADC:%d ", adc_value);
lcd_putstring(LINE1, (char *)buf);
}
/**
*********************************************************************************
***********
Function Name : main()
Description :
Input : Void
Output :
Note :
*********************************************************************************
*************
*/
int main (void)
{
init_adc0(); // Initialize ADC
init_lcd(); // Initialize LCD
wait(100000);
lcd_clear(); // clear display
33
while(1)
{
process_adc(); // Read ADC value and display it on first line
of LCD
wait(30000);
}
}
Lcd.h file
#ifndef _LCD_H
#define _LCD_H
#define MAX_CHAR_IN_ONE_LINE 16
enum ROW_NUMBERS
{
LINE1,
LINE2
};
void init_lcd(void);
void lcd_putstring(unsigned char line, char *string);
void lcd_clear(void);
void lcd_backlight_on(void);
int lcd_gotoxy(unsigned int x, unsigned int y);
void lcd_putchar(int c);
#endif
Adc.h file
#ifndef _ADC_H
#define _ADC_H
#define END_0F_CONVERSION_BIT (1<<31)
#define END_OF_CONVERSION(i) (i & END_0F_CONVERSION_BIT)
#define ADC_VALUE_MASK 0x03FF
#define ADC_CHANNEL_NUMBER_MASK 0x07
#define CHANNEL_0 0
#define CHANNEL_1 1
#define CHANNEL_2 2
#define CHANNEL_3 3
#define CHANNEL_4 4
34
#define CHANNEL_5 5
#define CHANNEL_6 6
#define CHANNEL_7 7
/* A/D Control Register */
#define AD0_0 0x00000001
#define AD0_1 0x00000002
#define AD0_2 0x00000004
#define AD0_3 0x00000008
#define AD0_4 0x00000010
#define AD0_5 0x00000020
#define AD0_6 0x00000040
#define AD0_7 0x00000080
#define AD1_0 0x00000001
#define AD1_1 0x00000002
#define AD1_2 0x00000004
#define AD1_3 0x00000008
#define AD1_4 0x00000010
#define AD1_5 0x00000020
#define AD1_6 0x00000040
#define AD1_7 0x00000080
#define CLKDIV_BIT0 (1<<8)
#define CLKDIV_BIT1 (1<<9)
#define CLKDIV_BIT2 (1<<10)
#define CLKDIV_BIT3 (1<<11)
#define CLKDIV_BIT4 (1<<12)
#define CLKDIV_BIT5 (1<<13)
#define CLKDIV_BIT6 (1<<14)
#define CLKDIV_BIT7 (1<<15)
#define BURST (1<<16) //to eneble burst mode
#define CLKS_BIT0 (1<<17)
#define CLKS_BIT1 (1<<18)
#define CLKS_BIT2 (1<<19)
#define PDN (1<<21)
#define START_BIT0 (1<<24)
#define START_BIT1 (1<<25)
#define START_BIT2 (1<<26)
#define EDGE (1<<27)
/* A/D Global Data Register */
#define OVERRUN (1L<<30)
35
#define DONE (1L<<31)
/* A/D Interrupt Enable Register */
#define ADINTEN0 (1<<0)
#define ADINTEN1 (1<<1)
#define ADINTEN2 (1<<2)
#define ADINTEN3 (1<<3)
#define ADINTEN4 (1<<4)
#define ADINTEN5 (1<<5)
#define ADINTEN6 (1<<6)
#define ADINTEN7 (1<<7)
#define ADGINTEN (1<<8)
#define ADC0 0
#define ADC1 1
#define ADC0CHANNELS 8
#define ADC1CHANNELS 8
#define POWER_DOWN_ADC0() AD0CR &= ~(PDN)
#define POWER_UP_ADC0() AD0CR |= (PDN)
#define POWER_DOWN_ADC1() AD1CR &= ~(PDN)
#define POWER_UP_ADC1() AD1CR |= (PDN)
//TN_EVENT EVT_ADC0;
//TN_EVENT EVT_ADC1;
void adc0_isr(void);
void adc1_isr(void);
void init_adc0( void );
void init_adc1( void );
unsigned short adc_read(unsigned char adc_num, unsigned char ch);
#endif
Adc.c file
#include "adc.h"
#include <LPC214x.H> /* LPC214x definitions */
/**
*******************************************************************************
Function Name :init_adc0()
36
Description : Initialises the ADC0
Input : None
Output : None
Note :
*******************************************************************************
*/
void init_adc0(void)
{
PINSEL1 = (PINSEL1 & ~(3 << 28)) | (1 << 28);
}
/**
*******************************************************************************
Function Name :init_adc1()
Description : Initialises the ADC1
Input : None
Output : None
Note :
*******************************************************************************
*/
void init_adc1(void)
{
}
/**
*******************************************************************************
Function Name : adc_read()
Description :
Input : adc number,channel
Output : 10 bit AD value
Note :
*******************************************************************************
*/
37
unsigned short adc_read(unsigned char adc_num, unsigned char ch)
{
unsigned int i=0;
switch(adc_num)
{
case ADC0:
AD0CR = 0x00200D00 | (1<<ch); // select channel
AD0CR |= 0x01000000; // Start A/D Conversion
do
{
i = AD0GDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion
break;
case ADC1:
AD1CR = 0x00200D00 | (1<<ch); // select channel
AD1CR |= 0x01000000; // Start A/D Conversion
do
{
i = AD1GDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion
break;
}
return (i >> 6) & 0x03FF; // bit 6:15 is 10 bit AD value
}
Result:
38
EXPERIMENT NO: 08
SERIAL COMMUNICATION
AIM: To write the program to perform serial communication using LPC2148 microcontroller.
APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic
HARDWARE REQUIREMENTS: LPC2148 development board, PC
PROGRAM:
#include <stdio.h> /* prototype declarations for I/O functions */
#include <LPC214x.H> /* LPC21xx definitions */
#include "Serial.h"
#define UART0_TEXT "nr Testing UART0 NGX's BlueBoard nr BlueBoard Revision : 1 nr
Firmware Version: 1 nr For more information on BlueBoard visit www.ngxtechnologies.com"
#define UART1_TEXT "nr Testing UART1 NGX's BlueBoard nr BlueBoard Revision : 1 nr
Firmware Version: 1 nr For more information on BlueBoard visit www.ngxtechnologies.com"
/**
**************************************************************************
****1111
Function Name : delay()
Description :This function suspends the tasks for specified ticks.
Input : ticks:no of ticks in multiple of 1 usec
task: task to be suspended
Output : void
Note :
*******************************************************************************
*/
void delay(int count)
{
int j=0,i=0;
for(j=0;j<count;j++)
{
/* At 60Mhz, the below loop introduces
delay of 10 us */
for(i=0;i<35;i++);
}
}
39
/****************/
/* main program */
/****************/
int main (void) { /* execution starts here */
uart0_init(); // Initialize UART0
while (1) { /* An embedded program does not stop */
//uart0_getkey();
uart0_puts (UART0_TEXT); // Transffer data to PC through Serial
delay(100000);
}
}
Serial.c file
#include <LPC21xx.H> /* LPC21xx definitions */
#include "Serial.h"
#define CR 0x0D
/* implementation of putchar (also used by printf function to output data) */
int sendchar (int ch) { /* Write character to Serial Port */
if (ch == 'n') {
while (!(U1LSR & 0x20));
U1THR = CR; /* output CR */
}
while (!(U1LSR & 0x20));
return (U1THR = ch);
}
int uart0_getkey (void) { /* Read character from Serial Port */
while (!(U0LSR & 0x01));
return (U0RBR);
}
int uart1_getkey (void) { /* Read character from Serial Port */
while (!(U1LSR & 0x01));
40
return (U1RBR);
}
void uart1_init()
{
/* initialize the serial interface */
PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U1LCR = 0x03; /* DLAB = 0 */
}
//------------------------------------------------------------------------------------------------//
//---------------------------- Function for send character 1 time via UART1-----------------------//
//------------------------------------------------------------------------------------------------//
void uart1_putc(char c)
{
while(!(U1LSR & 0x20)); // Wait until UART1 ready to send character
U1THR = c; // Send character
}
//------------------------------------------------------------------------------------------------//
//---------------------------- Function for send string via UART1---------------------------------//
//------------------------------------------------------------------------------------------------//
void uart1_puts(char *p)
{
while(*p) // Point to character
{
uart1_putc(*p++); // Send character then point to next character
}
}
//------------------------------------------------------------------------------------------------//
//---------------------------- Function for Initial UART0 ----------------------------------------//
//------------------------------------------------------------------------------------------------//
void uart0_init()
{
/* initialize the serial interface */
PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U0LCR = 0x03; /* DLAB = 0 */
}
//------------------------------------------------------------------------------------------------//
//---------------------------- Function for send character 1 time via UART0-----------------------//
//------------------------------------------------------------------------------------------------//
void uart0_putc(char c)
{
while(!(U0LSR & 0x20)); // Wait until UART0 ready to send character
U0THR = c; // Send character
41
}
//------------------------------------------------------------------------------------------------//
//---------------------------- Function for send string via UART1---------------------------------//
//------------------------------------------------------------------------------------------------//
void uart0_puts(char *p)
{
while(*p) // Point to character
{
uart0_putc(*p++); // Send character then point to next character
}
}
Serial.h file
int uart0_getkey(void);
int uart1_getkey(void);
void uart1_init (void);
void uart0_init (void);
void uart1_putc (char);
void uart0_putc (char);
void uart1_puts(char *);
void uart0_puts(char *);
Result:

More Related Content

What's hot

Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 CardOmar Sanchez
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Rodrigo Almeida
 
8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-trainJitendra Saroj
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19Rodrigo Almeida
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manualtwinkleratna
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)antonio michua
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics Felipe Prado
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerchirag patil
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerJhemi22
 
At 89c51
At 89c51At 89c51
At 89c51Mr Giap
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller pptRahul Kumar
 

What's hot (19)

Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
 
At89c2051 Data sheet
At89c2051 Data sheetAt89c2051 Data sheet
At89c2051 Data sheet
 
Uart
UartUart
Uart
 
8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train8449972 embedded-systems-and-model-of-metro-train
8449972 embedded-systems-and-model-of-metro-train
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
Lecture7
Lecture7Lecture7
Lecture7
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
 
At89s51
At89s51At89s51
At89s51
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
dspAt89 s52
dspAt89 s52dspAt89 s52
dspAt89 s52
 
Microcontroller ppt
Microcontroller pptMicrocontroller ppt
Microcontroller ppt
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
At 89c51
At 89c51At 89c51
At 89c51
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 

Viewers also liked

What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 

Viewers also liked (11)

Verilog lab mauual
Verilog lab mauualVerilog lab mauual
Verilog lab mauual
 
Vedic multiplier
Vedic multiplierVedic multiplier
Vedic multiplier
 
Sasi glp
Sasi glpSasi glp
Sasi glp
 
De lab manual
De lab manualDe lab manual
De lab manual
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
You Suck At PowerPoint!
You Suck At PowerPoint!You Suck At PowerPoint!
You Suck At PowerPoint!
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 

Similar to m.tech esd lab manual for record

Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACnanocdac
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counterMafaz Ahmed
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 
Embedded Systems using Microwave oven
Embedded Systems using  Microwave ovenEmbedded Systems using  Microwave oven
Embedded Systems using Microwave ovenBOOMIKAD
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming IIOmar Sanchez
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming IIOmar Sanchez
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleAarya Technologies
 
8051 microcontroller training (2) (sahil gupta 9068557926)
8051 microcontroller training  (2) (sahil gupta   9068557926)8051 microcontroller training  (2) (sahil gupta   9068557926)
8051 microcontroller training (2) (sahil gupta 9068557926)Sahil Gupta
 
Keypad locking system using 8051
Keypad locking system using 8051Keypad locking system using 8051
Keypad locking system using 8051manu anand
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 

Similar to m.tech esd lab manual for record (20)

report cs
report csreport cs
report cs
 
Jp
Jp Jp
Jp
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counter
 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
Embedded Systems using Microwave oven
Embedded Systems using  Microwave ovenEmbedded Systems using  Microwave oven
Embedded Systems using Microwave oven
 
Em s7 plc
Em s7 plcEm s7 plc
Em s7 plc
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
pandu-vivek (1)
pandu-vivek (1)pandu-vivek (1)
pandu-vivek (1)
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
8051 microcontroller training (2) (sahil gupta 9068557926)
8051 microcontroller training  (2) (sahil gupta   9068557926)8051 microcontroller training  (2) (sahil gupta   9068557926)
8051 microcontroller training (2) (sahil gupta 9068557926)
 
Keypad locking system using 8051
Keypad locking system using 8051Keypad locking system using 8051
Keypad locking system using 8051
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 

m.tech esd lab manual for record

  • 1. 1 INTRODUCTION DESCRIPTION OF EMBEDDED EVALUATION BOARD 1.1 INTRODUCTION The Embedded Controller Evaluation Board provides the user with the features required to understand the capabilities of an advanced microcontroller - the AT89C51ED2 Micro controller. The AT89C51ED2 is architecturally compatible with the Intel 89C51. The board consists of  The Flash programmable AT89C51ED2 controller  8 numbers of LED’s 8 numbers of Switches  16 X 2 Line LCD Alphanumeric Display  RS232C compatible Serial Interface for communication , ISP  SPI compatible 12 bit ADC with Temperature Sensor Interface  4 numbers of multiplexed 7- Segment Displays  I2C 8-bit ADC/DAC Interface  I2C RTC  I2C NVROM  4 numbers of high Current Output lines  One changeover Relay for Experiments  In System Programming capability 1.2 SPECIFICATIONS The Flash Programmable Embedded Controller Evaluation Board consists of  The Atmel 89C51ED2- 8-bit micro controller (U1) with operating frequency of 11.0592MHz with an external crystal and supply voltage of 5V. It has 64K bytes of flash memory block for program and data and 1792 bytes of XRAM  A 26 pin FRC connector CN3 connected to Ports 0,1 and 2 of the controller, which is compatible with ALS standard external interfaces.  26 pin FRC connector CN4 which can be connected to Port 0,1 and 2 Lines to study the internal features of the controller , Reading Switches, PWM, ADC, DAC, RTC, NVROM, 7-segment Displays etc.  A 9 pin D-type female connector CN2, RS232 serial i/o interface for UART experiments and flash programming.  A 9 pin D-type male Connector CN1 for power connection (+5V and GND).  Push buttons switch SW2 for Reset and a Slide switch SW1 to select either program mode or run mode.
  • 2. 2  Push buttons switch SW3 for External Interrupt INT0.  Eight numbers of LED's (L3 to L10) interfaced through serial shift register  Eight key switches (SW4 to SW11) organized in 2 rows X 4 columns  8bit ADC / DAC using I2C device (U17)  NVROM 24C16 – I2C compatible (U7)  RTC - DS1307 - I2C compatible (U6)  Four numbers CC seven segment multiplexed displays (U12,U13,U14,U15)  One DPDT relay with contact terminated in relaimate (RLY1)  Four High Current Output (300 ma) using ULN2803 (U16)  One SPI ADC (MCP3202) with Temperature Sensor IC LM335 (U4)  Elegant enclosure with Test Points for monitoring (TPs) 1.3 BLOCK DIAGRAM
  • 3. 3 1.4: APPLYING POWER Connect a 9-pin D-type(DB) Female Connector to a 9-pin DB Male connector CN1 provided on the Embedded Controller Evaluation Board (ALS-EMB-EVAL-02). The color code for the supply is Pin No Voltages Color Code(Female) 9 VCC(+5) Orange/White/Blue 4,5 GND Yellow/Black As soon as the power is applied the sign on message “EMBEDDED CONTROLLER EVALUATION BOARD” appears on the LCD. If the sign on message will not appear check the slide switch SW1 is in RUN position on the board and +5V is present at the corresponding VCC inputs of the IC pins. (Ex. Pin-44 of AT89C51ED2). If not switch off the power supply and verify that the IC's on the trainer are mounted properly or not. Press all the IC's tightly into their bases, switch on again and if sign on message still doesn't appears, refer to the factory. 1.5: SERIAL COMMUNICATION OPERATION To connect Embedded Controller Evaluation Board (ALS-EMB-EVAL-02) to host computer system the procedure is as follows - Connect one end of the 9-pin RS232 cross cable (Female Type) to the host computer system and other end (Male Type) to the serial port connector CN2 on the ALS-EMB-EVAL-02 board. Set the host computer system baud rate, data length and parity bit. The default values are 9600 baud, 1 stop bit and none parity bit. This setting is done in Device Manager explorer of the computer system. RS232 Cable Connection ALS-EMB-EVAL-02 Pin No(9 Pin Male DB) Host Computer Pin No (9 Pin Female DB) 2 (RXD) 2 (RXD) 3 (TXD) 3 (TXD) 5 (Signal GND) 5 (Signal GND)
  • 4. 4 EXPERIMENT NO: 01 LED BLINKING AIM: To write a program for the LEDs blinking. APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip HARDWARE: Embedded control evaluation board, PC PROGRAM: #include<at89c51xd2.h> #include<intrins.h> unsigned char ref_byte = 0xFF,temp,count =0x00; void DelayMs(unsigned int); void led_init(void); sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5 (Serial In Parralel Out) sbit LED = P2^7; //Data Line of the 8-bit shift reg U5 main() { AUXR = 0x10; //Accesiing Full XRAM CLKL = 0; led_init(); //Clearing ALL LEDs FROM L3 TO L10 DelayMs(1000); while(1) { temp = ref_byte; LED = (temp & 0x80)? 0:1; CLKL = 1; DelayMs(1); CLKL = 0; ref_byte <<= 1; count++; if(count == 0x08) { count = 0x00; ref_byte = 0x01; } DelayMs(1000); } } void DelayMs(unsigned int count) { // mSec Delay 11.0592 Mhz unsigned int i; while(count)
  • 5. 5 { i = 110; while(i>0) i--; count--; } } // To clear All LEDs void led_init(void) { unsigned int j; CLKL = 0; LED = 1; for(j=0;j<8;j++) { CLKL = 1; _nop_(); _nop_(); CLKL =0; _nop_(); } } OUTPUT: The LED blinking is being observed from L3 to L10 on the target board. RESULT: Thus the LED blinking program is being compiled, debugged and executed successfully.
  • 6. 6 EXPERIMENT NO: 02 PROGRAM ON TIMERS AIM: To write a program for DELAY using TIMER-0 and switch on a LED in timer subroutine. APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip HARDWARE: Embedded control evaluation board, PC PROGRAM: #include <at89c51xd2.h> #include <intrins.h> //For _nop_(); void led_init(void); void timer0_init(void); sbit L = P1^5; //LED L2 Operation sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5(Serial In parrale Out) sbit LED = P2^7; //Data Line of the 8-bit shift reg U5 void main(void) { AUXR = 0x10; // Accesiing Ful XRAM led_init(); //CLearing All LEDs from L3 to L10 timer0_init(); EA = 1; //Enabling Global Interrupt while(1); } void timer0_init(void) { TMOD = 0x01; //Timer0 in Mode1, TL0 = 0xff; TH0 = 0x6f; //For 40ms Delay TCON = 0x00; //TF0 = 0; //Clearing All Flags ET0 = 1; //Enabling Timer0 Interrupt TR0 = 1; //Starting Timer0 } void timer0_isr(void) interrupt 1 { L = ~L; //Toggling LED L2
  • 7. 7 TF0 = 0; //Clearing Interrupt Flag TL0 = 0xff; TH0 = 0x6f; //Reloading Value into registers for every overflow } // To clear All LEDs L3 to L10 void led_init(void) { unsigned int j; CLKL = 0; LED = 1; for(j=0;j<8;j++) { CLKL = 1; _nop_(); _nop_(); CLKL =0; _nop_(); } } OUTPUT: It is being observed that the routine delay of 40ms has been done. In ISR of timer0, LED L2 that is connected to port line P1.5 is being toggled for every 40ms. RESULT: Thus the program is being compiled, debugged and executed successfully.
  • 8. 8 EXPERIMENT NO: 03 LCD INTERFACE AIM: To write a program for LCD testing. . APPARATUS: SOFTWARE: Keil u IDE, Atmel Flip HARDWARE: Embedded control evaluation board, PC PROGRAM: #include<at89c51xd2.h> #include<intrins.h> // LCD FUNCTION PROTOTYPE void lcd_init(void); void lcd_comm(void); void wr_cn(void); void lcd_data(void); void wr_dn(void); void clear_lcd(void); void maxdelay(void); void mindelay(void); unsigned int i=0; unsigned char temp1=0x00,var=0x00; unsigned char temp2; void led_init(void); unsigned char arr[32] = " EMBEDDED SYSTEMS AND VLSI "; sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5 (Serial In Parralel Out) sbit LED = P2^7; //Data Line of the 8-bit shift reg U5 void main(void) { AUXR = 0x10; // Accesiing Ful XRAM led_init(); //CLearing All LEDs from L3 to L10 lcd_init(); // Initialize the LCD clear_lcd(); temp1 = 0x80; lcd_comm(); // Displaying at 1st line of LCD for(i=0;i<32;i++) { if(i == 16) {
  • 9. 9 temp1 = 0xc0; lcd_comm(); // Displaying at 2nd line of LCD } temp2 = arr[i]; lcd_data(); } while(1); } void lcd_init(void) { temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1 wr_cn(); maxdelay(); temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1 wr_cn(); maxdelay(); temp1 = 0x0C; // D5(P3.3)=1,D4(P3.2)=1 wr_cn(); maxdelay(); temp1 = 0x08; // D5(P3.3)=1 wr_cn(); maxdelay(); temp1 = 0x28; lcd_comm(); maxdelay(); temp1 = 0x0f; //display on,cursor on lcd_comm(); maxdelay(); temp1 = 0x06; //shift cursor right with auto increment lcd_comm(); maxdelay(); temp1 = 0x80; //clear display with cursor on first position lcd_comm(); maxdelay(); } // Function to pass commands to LCD void lcd_comm(void) { var = temp1; temp1 = temp1 & 0xf0;
  • 10. 10 temp1 = temp1 >> 2; wr_cn(); temp1 = var & 0x0f; temp1 = temp1 << 2; wr_cn(); mindelay(); } // Function to pass data to LCD void lcd_data(void) { var = temp2; temp2 = temp2 & 0xf0; // convert the byte into nibble temp2 = temp2 >> 2; wr_dn(); temp2 = var & 0x0f; temp2 = temp2 << 2; wr_dn(); mindelay(); } // Function to write to command reg of LCD void wr_cn(void) { temp1 = temp1 & 0x7f; // RS(P3^7)=0 temp1 = temp1 | 0x43; // EN(P3^6)=1, TXD(P3^1)=1, RXD(P3^0)=1 P3 = temp1; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); temp1 = temp1 & 0xbf; // EN(P3^6)=0, P3 = temp1; } // Function to write to data reg of LCD void wr_dn(void) { temp2 = temp2 | 0xc3; // RS(P3^7)=1,EN=1,TXD=1,RXD=1 P3 = temp2;
  • 11. 11 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); temp2 = temp2 & 0xbf; // EN = 0 P3 = temp2; } // Function to clear the LCD display void clear_lcd() { temp1 = 0x01; lcd_comm(); maxdelay(); } void maxdelay(void) { int i,j; /* for(i=0;i<5;i++) for(j=0;j<50;j++); //2.1ms Delay*/ for(i=0;i<10;i++) for(j=0;j<50;j++); //4.1ms Delay*/ } void mindelay(void) { int j; for(j=0;j<60;j++); //0.52ms Delay } // To clear All LEDs L3 to L10 void led_init(void) { unsigned int j; CLKL = 0; LED = 1; for(j=0;j<8;j++) { CLKL = 1; _nop_(); _nop_(); CLKL =0; _nop_(); }
  • 12. 12 } OUTPUT: “EMBEDDED SYSTEMS AND VLSI” is being observed on the LCD screen. RESULT: Thus the LCD TEST program is being compiled, debugged and executed successfully.
  • 13. 13 EXPERIMENT NO: 04 KEYPAD INTERFACE AIM: To write the program to interface keypad to 8051. APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Atmel Flip HARDWARE REQUIREMENTS: Embedded control evaluation board, PC PROGRAM: #include<at89c51xd2.h> #include<intrins.h> /*key_arr :--> 0x8E -> ROW2 SW8 0x1E -> ROW1 SW4 0x8D -> ROW2 SW9 0x1D -> ROW1 SW5 0x8B -> ROW2 SW10 0x1B -> ROW1 SW6 0x87 -> ROW2 SW11 0x17 -> ROW1 SW7 0x8E,0x8D,0x8B,0x87 -> 8(1000) is for ROW2(P2.4*)=0;ROW1(P1.7*)=1 0x1E,0x1D,0x1B,0x17 -> 1(0001) is for ROW1(P1.7*)=0;ROW2(P2.4*)=1 E -> 1110 -> for P2.0* SW4 & SW8 D -> 1101 -> for P2.1* SW5 & SW9 D -> 1011 -> for P2.2* SW6 & SW10 D -> 0111 -> for P2.3* SW7 & SW11 */ unsigned char key_arr[8] = {0x8E,0x8D,0x8B,0x87,0x1E,0x1D,0x1B,0x17}; /*array_dec[10]:-> value= h g f e d c b a On 7-SEG U15 0x66 = 0 1 1 0 0 1 1 0 -> Displaying '4' 0x6D = 0 1 1 0 1 1 0 1 -> Displaying '5' 0x7D = 0 1 1 1 1 1 0 1 -> Displaying '6' 0x07 = 0 0 0 0 0 1 1 1 -> Displaying '7' 0x3F = 0 0 1 1 1 1 1 1 -> Displaying '0' 0x06 = 0 0 0 0 0 1 1 0 -> Displaying '1' 0x5B = 0 1 0 1 1 0 1 1 -> Displaying '2' 0x4F = 0 1 0 0 1 1 1 1 -> Displaying '3' 0x7F = 0 1 1 1 1 1 1 1 -> Displaying '8' 0x6F = 0 1 1 0 1 1 1 1 -> Displaying '9' */ unsigned char array_dec[10] = {0x66,0x6D,0x7D,0x07,0x3F,0x06,0x5B,0x4F,0x7F,0x6F}; unsigned char key_rtn=0x00,key_flag=0x00,temp =0x00,temp2 = 0x00; unsigned char row = 0xEF,temp_row = 0x00,key = 0x00,tmp_rw1=0x00,tmp_rw2=0x00; unsigned int i = 0; void key_press(void); void scan(void); void DelayMs(unsigned int); void Display(void); void led_init(void);
  • 14. 14 sbit EN = P1^2; //Latch Enable Line of second 2to4 LineDecoder of U8 //U8 is having two 2to4 line decoders sbit SEL0 = P1^3; //Data Latch 1A of the 1st decoder of U8 sbit SEL1 = P1^5; //Data Latch 1B of the 1st decoder of U8 sbit ENL = P2^5; //Data Latch 2B of the 2nd decoder of U8 sbit ROW2 = P2^4; //Second row of thw 2X4 keypad sbit ROW1 = P1^7; //First row of thw 2X4 keypad sbit CS = P1^4; //Chip select line for SPI device U3 sbit CLKL = P2^6; //Clock Line (>CLK)of 8-bit shift reg U5(Serial In parrale Out) sbit LED = P2^7; //Data Line of the 8-bit shift reg U5 void main() { AUXR = 0x10;//Accessing Ful XRAM led_init(); //For Clearing All LEDs L3 to L10 P2 = 0xFF; //make Port 2 high; P1 = 0xFF; //make Port 1 high; P0 = 0x00; //port for 7-seg data EN = 1; //Disabling 2nd Decoder ENL = 0; //Data Latch Enable line CS = 1; //to disable SPI while(1) { ROW1 = 0; //fOR ROW1 (SW4 TO SW 7) ROW2 = 1; key_press(); if(key_flag == 0xFF)//If key Pressed { scan(); Display(); //Displying the num on the 7-Seg U15 } ROW1 = 1; //fOR ROW2 (SW8 TO SW 11) ROW2 = 0; key_press(); if(key_flag == 0xFF)//If key Pressed { scan(); Display(); //Displying the num on the 7-Seg U15 } } //end of while(1) loop } /* Key_press() function is used to check which portline has gone LO Initialy the portlines P2.0*,P2.1*,P2.2*,P2.3* are HI, so when pressing SWitches the perticular portline goes LO (Such that LO at P1.7* will go to the perticular portline P2.0* to P2.3*). P1.7* and P2.4* are Outpuit Lines P2.7* to P2.3* are input lines to Contrller */
  • 15. 15 void key_press(void) { temp = P2 & 0x0F; //Read the keys(Masking the Lowr Nibble) DelayMs(1); //wait for debounce temp = P2 & 0x0F; //Again Read the keys(Masking the Lowr Nibble) DelayMs(1); //wait for debounce if(temp == 0x0F) //If No key has been pressed key_flag = 0x00; else { key_flag = 0xFF;//If Key pressed DelayMs(1); //wait for debounce while(temp == (temp2 = P2 & 0x0F));//waiting for key lift key_rtn = temp; //taking the value read 'temp' wen pressing key //i.e. P2=0x0F (Initialy P2.0 to P2.3 are at HI) //P2=0x0E wen SW4 0r SW8 are pressed depending upon ROW1&ROW2 //P2=0x0D wen SW5 0r SW9 are pressed depending upon ROW1&ROW2 //P2=0x0B wen SW6 0r SW10 are pressed depending upon ROW1&ROW2 //P2=0x07 wen SW7 0r SW11 are pressed depending upon ROW1&ROW2 } } /* scan() function is used for masking perticular ROW line and getting it in one variable,after this combining the masked ROW line with the COL lines... The reult carible is being compared with the Lookup Table key_arr[] and getting the corresponding index of the Display array array_dec[] For Ex: For key_arr[i=0] = 0x8E; key = i = 0 array_dec[key] = 0x66 '4' For key_arr[i=3] = 0x87; key = i = 3 array_dec[key] = 0x07 '7' For key_arr{i=4] = 0x1E; key = i = 4 array_dec[key] = 0x3F '0' For key_arr{i=6] = 0x1B; key = i = 6 array_dec[key] = 0x5B '2' */ void scan(void) { tmp_rw1 = P1 & 0x80; //Masking P1.7* portline tmp_rw2 = tmp_rw1 | (P2 & 0x10);//Masking P2.4* portline tmp_rw2 = tmp_rw2 & 0x90; //Again Masking P1.7* & P2.4* key_rtn = key_rtn | tmp_rw2; //Combining ROWs(P1.7*&P2.4*)//and COLs(P2.0* to P2.3*) for(i=0;i<8;i++) if(key_rtn == key_arr[i]) key = i; //Getting the correspondin index value for //displaying 0,1,2,3,4,5,6,7 on U15 } /*Portlines P0.0* to P0.7* are given to the 7 segment displays thru Buffer
  • 16. 16 P0.0* to P0.7* ===> a,b,c,d,e,f,g,h segments respectivly */ void Display(void) { P0 = array_dec[key];//Decoding the key value to that of 7-segment ENL = 0; SEL1 = 1; //Select lines for segments SEL0 = 1; //00 for U12,01 for U13 //10 for U14,11 for U15 EN = 0; DelayMs(2); EN = 1; } void DelayMs(unsigned int count) { // 0.1 mSec Delay 11.0592 Mhz unsigned int i; while(count) { i = 11; while(i>0) i--; count--; } } // To clear All LEDs void led_init(void) { unsigned int j; CLKL = 0; LED = 1; for(j=0;j<8;j++) { CLKL = 1; _nop_(); _nop_(); CLKL =0; _nop_(); } } OUTPUT: It is being observed that key numbers 0 to 7 for switches SW4 to SW11 respectively displayed on the right most 7-segment display U15. RESULT: Thus the keypad program is being compiled, debugged and executed successfully.
  • 17. 17 EXPERIMENT NO: 05 KEYPAD INTERFACE AIM: To write the program to interface LCD to ARM7(LPC2148) microcontroller. APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic HARDWARE REQUIREMENTS: LPC2148 development board, PC PROGRAM: main.c file #include "lcd.h" int main (void) { init_lcd(); while (1) { lcd_data_write('a'); } } lcd.c file #include <LPC214x.H> /* LPC214x definitions */ #include "lcd.h" #define LCD_BACK_LIGHT_TIMEOUT 1000 #define LCD_BACKLIGHT (1 << 21) #define LCD_BACK_LIGHT_DIR IO1DIR #define LCD_BACK_LIGHT_SET IO1SET #define LCD_BACK_LIGHT_CLR IO1CLR #define LCD_DATA_DIR IO0DIR #define LCD_DATA_SET IO0SET #define LCD_DATA_CLR IO0CLR #define LCD_CTRL_DIR IO1DIR #define LCD_CTRL_SET IO1SET #define LCD_CTRL_CLR IO1CLR #define LCDRS (1 << 24) #define LCDRW (1 << 23) #define LCDEN (1 << 22)
  • 18. 18 #define LCD_D4 (1 << 10) #define LCD_D5 (1 << 11) #define LCD_D6 (1 << 12) #define LCD_D7 (1 << 13) #define LCD_DATA_MASK (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7) #define LCD_BUSY_FLAG LCD_D7 #define LCD_CONTROL_MASK 0x01C00000 /** ************************************************************************** ****1111 Function Name : delay() Description :This function suspends the tasks for specified ticks. Input : ticks:no of ticks in multiple of 1 usec task: task to be suspended Output : void Note : ******************************************************************************* */ void delay(int count) { int j=0,i=0; for(j=0;j<count;j++) { /* At 60Mhz, the below loop introduces delay of 10 us */ for(i=0;i<35;i++); } } /** ********************************************************************************* *********** Function Name : wait_lcd() Description : Input :
  • 19. 19 Output : Void Note : ********************************************************************************* *********** */ void wait_lcd( void ) { LCD_CTRL_CLR |= LCDRS; LCD_CTRL_SET |= LCDRW |LCDEN; while(IO1PIN & LCD_BUSY_FLAG); /* wait for busy flag to become low */ LCD_CTRL_CLR |= LCDEN | LCDRW; LCD_DATA_DIR |= LCD_DATA_MASK; delay(100); } /** ********************************************************************************* *********** Function Name : lcd_command_write() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void lcd_command_write( unsigned char command ) { unsigned char temp=0; unsigned int temp1=0; temp=command; temp=(temp>>4)&0x0F; temp1=(temp<<10)&LCD_DATA_MASK; LCD_CTRL_CLR = LCDRS; LCD_CTRL_SET = LCDEN; LCD_DATA_CLR = LCD_DATA_MASK; LCD_DATA_SET = temp1; delay(10000);
  • 20. 20 LCD_CTRL_CLR = LCDEN; temp=command; temp&=0x0F; temp1=(temp<<10)&LCD_DATA_MASK; delay(100*2); LCD_CTRL_CLR |= LCDRS; LCD_CTRL_SET |= LCDEN; LCD_DATA_CLR = LCD_DATA_MASK; LCD_DATA_SET = temp1; delay(10000); LCD_CTRL_CLR |= LCDEN; wait_lcd(); } /** ********************************************************************************* *********** Function Name : set_lcd_port_output() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void set_lcd_port_output( void ) { LCD_CTRL_DIR |= ( LCDEN | LCDRS | LCDRW ); LCD_CTRL_CLR |= ( LCDEN | LCDRS | LCDRW ); LCD_DATA_DIR |= LCD_DATA_MASK; } /* * ********************************************************************************* *********** Function Name : lcd_clear() Description : Input : Output : Void
  • 21. 21 Note : ********************************************************************************* *********** */ void lcd_clear( void) { lcd_command_write( 0x01 ); } /** ********************************************************************************* *********** Function Name : lcd_gotoxy() Description : Input : Output : Void Note : ********************************************************************************* *********** */ int lcd_gotoxy( unsigned int x, unsigned int y) { int retval = 0; if( (x > 1) && (y > 15) ) { retval = -1; } else { if( x == 0 ) { lcd_command_write( 0x80 + y ); /* command - position cursor at 0x00 (0x80 + 0x00 ) */ } else if( x==1 ){ lcd_command_write( 0xC0 + y ); /* command - position cursor at 0x40 (0x80 + 0x00 ) */ } } return retval; } /** ********************************************************************************* *********** Function Name : lcd_data_write()
  • 22. 22 Description : Input : Output : Void Note : ********************************************************************************* *********** */ void lcd_data_write( unsigned char data ) { unsigned char temp=0; unsigned int temp1=0; temp=data; temp=(temp>>4)&0x0F; temp1=(temp<<10)&LCD_DATA_MASK; LCD_CTRL_SET |= LCDEN|LCDRS; LCD_DATA_CLR = LCD_DATA_MASK; LCD_DATA_SET = temp1; LCD_CTRL_CLR |= LCDEN; temp=data; temp&=0x0F; temp1=(temp<<10)&LCD_DATA_MASK; LCD_CTRL_SET |= LCDEN|LCDRS; LCD_DATA_CLR = LCD_DATA_MASK; LCD_DATA_SET = temp1; LCD_CTRL_CLR |= LCDEN; wait_lcd(); } /** ********************************************************************************* *********** Function Name : lcd_putchar() Description : Input : Output : Void Note :
  • 23. 23 ********************************************************************************* *********** */ void lcd_putchar( int c ) { lcd_data_write( c ); } /** ********************************************************************************* *********** Function Name : lcd_putstring() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void lcd_putstring( unsigned char line, char *string ) { unsigned char len = MAX_CHAR_IN_ONE_LINE; lcd_gotoxy( line, 0 ); while(*string != '0' && len--) { lcd_putchar( *string ); string++; } } /** ********************************************************************************* *********** Function Name : lcd_backlight_on() Description : Input : Output : Void Note :
  • 24. 24 ********************************************************************************* *********** */ void lcd_backlight_on() { LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT; LCD_BACK_LIGHT_SET |= LCD_BACKLIGHT; } /** ********************************************************************************* *********** Function Name : turn_off_lcd_back_light() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void turn_off_lcd_back_light_cb(void) { LCD_BACK_LIGHT_DIR |= LCD_BACKLIGHT; LCD_BACK_LIGHT_CLR |= LCD_BACKLIGHT; } /** ********************************************************************************* *********** Function Name : init_lcd() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void init_lcd( void ) {
  • 25. 25 set_lcd_port_output(); delay(100*100); lcd_command_write(0x28); /* 4-bit interface, two line, 5X7 dots. */ lcd_clear() ; /* LCD clear */ lcd_command_write(0x02); /* cursor home */ lcd_command_write(0x06); /* cursor move direction */ lcd_command_write(0x0C) ; /* display on */ lcd_gotoxy(0, 0); lcd_clear(); lcd_putstring(0," N G X "); lcd_putstring(1," TECHNOLOGIES "); } #ifndef _LCD_H #define _LCD_H #define MAX_CHAR_IN_ONE_LINE 16 enum ROW_NUMBERS { LINE1, LINE2 }; void init_lcd(void); void lcd_putstring(unsigned char line, char *string); void lcd_clear(void); void lcd_backlight_on(void); int lcd_gotoxy(unsigned int x, unsigned int y); void lcd_putchar(int c); #endif Result:
  • 26. 26 EXPERIMENT NO: 06 EXTERNAL INTERRUPT HANDLER AIM: To write the program for external interrupt handler for ARM7(LPC2148) and turn on buzzer on interrupt. APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic HARDWARE REQUIREMENTS: LPC2148 development board, PC PROGRAM: Main.c file #include <LPC214x.H> /* LPC21xx definitions */ #include "ext_int.h" int main (void) { init_ext_interrupt(); // initialize the external interrup while (1) { } } Ext_int.h #ifndef _KEYPAD_H #define _KEYPAD_H #include <LPC214x.H> /* LPC21xx definitions */ #define KEY_NOT_PRESSED 0xFF #define KEYPAD_DATA_DIR IODIR1 #define KEYPAD_DATA IOPIN1 #define KEYPAD_COL_SET IOSET1 #define KEYPAD_ROW_SET IOSET1 #define KEYPAD_COL_CLR IOCLR1 #define KEYPAD_ROW_CLR IOCLR1 #define COL_MASK (COL0 | COL1 | COL2 | COL3) #define ROW_MASK (ROW0 | ROW1 | ROW2 | ROW3) #define COL0 (1 << 21) #define COL1 (1 << 22) #define COL2 (1 << 23) #define COL3 (1 << 24)
  • 27. 27 #define ROW0 (1 << 17) #define ROW1 (1 << 18) #define ROW2 (1 << 19) #define ROW3 (1 << 20) void init_ext_interrupt(void); unsigned char key_hit(unsigned char **key); void Ext_ISR(void) __irq; unsigned char read_key(void); #endif Ext_int.c file #include <LPC214x.H> /* LPC21xx definitions */ #include "Ext_Int.h" #include "buzzer.h" #define EXTINT_EINT2_MASK 0x4 #define EXTMODE_EXTMODE2_MASK 0x4 #define EXTPOLAR_EXTPOLAR2_MASK 0x4 // Vector Control Register bit definitions #define VIC_ENABLE (1 << 5) // Convert Channel Number to Bit Value #define VIC_BIT(chan) (1 << (chan)) #define VIC_EINT2 16 /** ************************************************************************** ****1111 Function Name : delay() Description :This function suspends the tasks for specified ticks. Input : ticks:no of ticks in multiple of 1 usec task: task to be suspended Output : void Note : ******************************************************************************* */
  • 28. 28 void delay(int count) { int j=0,i=0; for(j=0;j<count;j++) { /* At 60Mhz, the below loop introduces delay of 10 us */ for(i=0;i<35;i++); } } /** ********************************************************************************* *********** Function Name : key_init() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void init_ext_interrupt() { EXTMODE = EXTMODE_EXTMODE2_MASK; EXTPOLAR &= ~EXTPOLAR_EXTPOLAR2_MASK; PINSEL0 = (PINSEL0 & ~(3U << 30)) | (1U << 31); /* initialize the interrupt vector */ VICIntSelect &= ~ VIC_BIT(VIC_EINT2); // EINT0 selected as IRQ VICVectAddr5 = (unsigned int)Ext_ISR; // address of the ISR VICVectCntl5 = VIC_ENABLE | VIC_EINT2; VICIntEnable = VIC_BIT(VIC_EINT2); // EINT0 interrupt enabled EXTINT &= ~EXTINT_EINT2_MASK; } /** ********************************************************************************* ***********
  • 29. 29 Function Name : keypad_ISR() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void Ext_ISR(void) __irq { turn_on_buzzer(); delay(10000); turn_off_buzzer(); EXTINT |= EXTINT_EINT2_MASK; //clear interrupt VICVectAddr = 0; } Buzzer.h file #ifndef _BUZZER_H #define _BUZZER_H void turn_on_buzzer(void); void turn_off_buzzer(void); #endif // _BUZZER_H Buzzer.c file #include <LPC214x.H> /* LPC21xx definitions */ #define BUZZER (1 << 25) #define BUZZER_DIR IO1DIR #define BUZZER_SET IO1SET #define BUZZER_CLR IO1CLR /** ********************************************************************************* *********** Function Name : turn_on_buzzer()
  • 30. 30 Description : Input : Output : Void Note : ********************************************************************************* *********** */ void turn_on_buzzer() { BUZZER_DIR |= BUZZER; BUZZER_CLR |= BUZZER; } /** ********************************************************************************* *********** Function Name : turn_off_lcd_back_light() Description : Input : Output : Void Note : ********************************************************************************* *********** */ void turn_off_buzzer(void) { BUZZER_DIR |= BUZZER; BUZZER_SET |= BUZZER; }
  • 31. 31 EXPERIMENT NO: 07 ANALOG TO DIGITAL CONVERSION AIM: To write the program for analog to digital conversion and and display the digital value on LCD. APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic HARDWARE REQUIREMENTS: LPC2148 development board, PC PROGRAM: Main.c file #include <stdio.h> #include <LPC214x.H> /* LPC214x definitions */ #include "lcd.h" #include "adc.h" /** ************************************************************************** ****1111 Function Name : wait() Description :This function suspends the tasks for specified ticks. Input : ticks:no of ticks in multiple of 1 usec task: task to be suspended Output : void Note : ******************************************************************************* */ void wait(int count) { int j=0,i=0; for(j=0;j<count;j++) { /* At 60Mhz, the below loop introduces delay of 10 us */ for(i=0;i<35;i++); } } /**
  • 32. 32 ********************************************************************************* *********** Function Name : process_adc() Description : Input : Void Output : Void Note : ********************************************************************************* ************* */ void process_adc(void) { unsigned short adc_value = 0; unsigned char buf[16] = {0}; adc_value = adc_read(ADC0, CHANNEL_3); sprintf((char *)buf, "ADC:%d ", adc_value); lcd_putstring(LINE1, (char *)buf); } /** ********************************************************************************* *********** Function Name : main() Description : Input : Void Output : Note : ********************************************************************************* ************* */ int main (void) { init_adc0(); // Initialize ADC init_lcd(); // Initialize LCD wait(100000); lcd_clear(); // clear display
  • 33. 33 while(1) { process_adc(); // Read ADC value and display it on first line of LCD wait(30000); } } Lcd.h file #ifndef _LCD_H #define _LCD_H #define MAX_CHAR_IN_ONE_LINE 16 enum ROW_NUMBERS { LINE1, LINE2 }; void init_lcd(void); void lcd_putstring(unsigned char line, char *string); void lcd_clear(void); void lcd_backlight_on(void); int lcd_gotoxy(unsigned int x, unsigned int y); void lcd_putchar(int c); #endif Adc.h file #ifndef _ADC_H #define _ADC_H #define END_0F_CONVERSION_BIT (1<<31) #define END_OF_CONVERSION(i) (i & END_0F_CONVERSION_BIT) #define ADC_VALUE_MASK 0x03FF #define ADC_CHANNEL_NUMBER_MASK 0x07 #define CHANNEL_0 0 #define CHANNEL_1 1 #define CHANNEL_2 2 #define CHANNEL_3 3 #define CHANNEL_4 4
  • 34. 34 #define CHANNEL_5 5 #define CHANNEL_6 6 #define CHANNEL_7 7 /* A/D Control Register */ #define AD0_0 0x00000001 #define AD0_1 0x00000002 #define AD0_2 0x00000004 #define AD0_3 0x00000008 #define AD0_4 0x00000010 #define AD0_5 0x00000020 #define AD0_6 0x00000040 #define AD0_7 0x00000080 #define AD1_0 0x00000001 #define AD1_1 0x00000002 #define AD1_2 0x00000004 #define AD1_3 0x00000008 #define AD1_4 0x00000010 #define AD1_5 0x00000020 #define AD1_6 0x00000040 #define AD1_7 0x00000080 #define CLKDIV_BIT0 (1<<8) #define CLKDIV_BIT1 (1<<9) #define CLKDIV_BIT2 (1<<10) #define CLKDIV_BIT3 (1<<11) #define CLKDIV_BIT4 (1<<12) #define CLKDIV_BIT5 (1<<13) #define CLKDIV_BIT6 (1<<14) #define CLKDIV_BIT7 (1<<15) #define BURST (1<<16) //to eneble burst mode #define CLKS_BIT0 (1<<17) #define CLKS_BIT1 (1<<18) #define CLKS_BIT2 (1<<19) #define PDN (1<<21) #define START_BIT0 (1<<24) #define START_BIT1 (1<<25) #define START_BIT2 (1<<26) #define EDGE (1<<27) /* A/D Global Data Register */ #define OVERRUN (1L<<30)
  • 35. 35 #define DONE (1L<<31) /* A/D Interrupt Enable Register */ #define ADINTEN0 (1<<0) #define ADINTEN1 (1<<1) #define ADINTEN2 (1<<2) #define ADINTEN3 (1<<3) #define ADINTEN4 (1<<4) #define ADINTEN5 (1<<5) #define ADINTEN6 (1<<6) #define ADINTEN7 (1<<7) #define ADGINTEN (1<<8) #define ADC0 0 #define ADC1 1 #define ADC0CHANNELS 8 #define ADC1CHANNELS 8 #define POWER_DOWN_ADC0() AD0CR &= ~(PDN) #define POWER_UP_ADC0() AD0CR |= (PDN) #define POWER_DOWN_ADC1() AD1CR &= ~(PDN) #define POWER_UP_ADC1() AD1CR |= (PDN) //TN_EVENT EVT_ADC0; //TN_EVENT EVT_ADC1; void adc0_isr(void); void adc1_isr(void); void init_adc0( void ); void init_adc1( void ); unsigned short adc_read(unsigned char adc_num, unsigned char ch); #endif Adc.c file #include "adc.h" #include <LPC214x.H> /* LPC214x definitions */ /** ******************************************************************************* Function Name :init_adc0()
  • 36. 36 Description : Initialises the ADC0 Input : None Output : None Note : ******************************************************************************* */ void init_adc0(void) { PINSEL1 = (PINSEL1 & ~(3 << 28)) | (1 << 28); } /** ******************************************************************************* Function Name :init_adc1() Description : Initialises the ADC1 Input : None Output : None Note : ******************************************************************************* */ void init_adc1(void) { } /** ******************************************************************************* Function Name : adc_read() Description : Input : adc number,channel Output : 10 bit AD value Note : ******************************************************************************* */
  • 37. 37 unsigned short adc_read(unsigned char adc_num, unsigned char ch) { unsigned int i=0; switch(adc_num) { case ADC0: AD0CR = 0x00200D00 | (1<<ch); // select channel AD0CR |= 0x01000000; // Start A/D Conversion do { i = AD0GDR; // Read A/D Data Register } while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion break; case ADC1: AD1CR = 0x00200D00 | (1<<ch); // select channel AD1CR |= 0x01000000; // Start A/D Conversion do { i = AD1GDR; // Read A/D Data Register } while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion break; } return (i >> 6) & 0x03FF; // bit 6:15 is 10 bit AD value } Result:
  • 38. 38 EXPERIMENT NO: 08 SERIAL COMMUNICATION AIM: To write the program to perform serial communication using LPC2148 microcontroller. APPARATUS: SOFTWARE REQUIREMENTS: Keil u IDE, Flash Magiic HARDWARE REQUIREMENTS: LPC2148 development board, PC PROGRAM: #include <stdio.h> /* prototype declarations for I/O functions */ #include <LPC214x.H> /* LPC21xx definitions */ #include "Serial.h" #define UART0_TEXT "nr Testing UART0 NGX's BlueBoard nr BlueBoard Revision : 1 nr Firmware Version: 1 nr For more information on BlueBoard visit www.ngxtechnologies.com" #define UART1_TEXT "nr Testing UART1 NGX's BlueBoard nr BlueBoard Revision : 1 nr Firmware Version: 1 nr For more information on BlueBoard visit www.ngxtechnologies.com" /** ************************************************************************** ****1111 Function Name : delay() Description :This function suspends the tasks for specified ticks. Input : ticks:no of ticks in multiple of 1 usec task: task to be suspended Output : void Note : ******************************************************************************* */ void delay(int count) { int j=0,i=0; for(j=0;j<count;j++) { /* At 60Mhz, the below loop introduces delay of 10 us */ for(i=0;i<35;i++); } }
  • 39. 39 /****************/ /* main program */ /****************/ int main (void) { /* execution starts here */ uart0_init(); // Initialize UART0 while (1) { /* An embedded program does not stop */ //uart0_getkey(); uart0_puts (UART0_TEXT); // Transffer data to PC through Serial delay(100000); } } Serial.c file #include <LPC21xx.H> /* LPC21xx definitions */ #include "Serial.h" #define CR 0x0D /* implementation of putchar (also used by printf function to output data) */ int sendchar (int ch) { /* Write character to Serial Port */ if (ch == 'n') { while (!(U1LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U1LSR & 0x20)); return (U1THR = ch); } int uart0_getkey (void) { /* Read character from Serial Port */ while (!(U0LSR & 0x01)); return (U0RBR); } int uart1_getkey (void) { /* Read character from Serial Port */ while (!(U1LSR & 0x01));
  • 40. 40 return (U1RBR); } void uart1_init() { /* initialize the serial interface */ PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */ } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send character 1 time via UART1-----------------------// //------------------------------------------------------------------------------------------------// void uart1_putc(char c) { while(!(U1LSR & 0x20)); // Wait until UART1 ready to send character U1THR = c; // Send character } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send string via UART1---------------------------------// //------------------------------------------------------------------------------------------------// void uart1_puts(char *p) { while(*p) // Point to character { uart1_putc(*p++); // Send character then point to next character } } //------------------------------------------------------------------------------------------------// //---------------------------- Function for Initial UART0 ----------------------------------------// //------------------------------------------------------------------------------------------------// void uart0_init() { /* initialize the serial interface */ PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */ U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U0LCR = 0x03; /* DLAB = 0 */ } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send character 1 time via UART0-----------------------// //------------------------------------------------------------------------------------------------// void uart0_putc(char c) { while(!(U0LSR & 0x20)); // Wait until UART0 ready to send character U0THR = c; // Send character
  • 41. 41 } //------------------------------------------------------------------------------------------------// //---------------------------- Function for send string via UART1---------------------------------// //------------------------------------------------------------------------------------------------// void uart0_puts(char *p) { while(*p) // Point to character { uart0_putc(*p++); // Send character then point to next character } } Serial.h file int uart0_getkey(void); int uart1_getkey(void); void uart1_init (void); void uart0_init (void); void uart1_putc (char); void uart0_putc (char); void uart1_puts(char *); void uart0_puts(char *); Result: