0% found this document useful (0 votes)
185 views57 pages

ARM Full Manual

ARM full manual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views57 pages

ARM Full Manual

ARM full manual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 57

Laboratory manual-18ECE204J (ARM-based Embedded System Design)

Academic year 2022-23

Prepared by Course coordinator


SRM Institute of Science and Technology
Department of Electronics and Communication Engineering
Vision of the Department
1. To create and disseminate knowledge in the area of Electronics and Communication
Engineering through national and international accredited educational process.
2. To facilitate a unique learning and research experience to the students and faculty.
3. To prepare the students as highly ethical and competent professionals.

Mission of the Department


1. Build an educational process that is well suited to local needs as well as satisfies the national
and international accreditation requirements.
2. Attract the qualified professionals and retain them by building an environment that fosters
work freedom and empowerment.
3. With the right talent pool, create knowledge and disseminate, get involved in collaborative
research with reputed universities and produce competent graduands.

Program Educational Objectives (PEO)


Program Educational Objectives for the Electronics and Communication Engineering program
describes accomplishments that graduates are expected to attain within a few years of graduation.
Graduates will be able to:
PEO1: Establish themselves as successful and creative practicing professional engineers both
nationally and globally in the related fields of Electronics and Communication Engineering.
PEO2: Apply the acquired knowledge and skills in solving real-world engineering problems; develop
novel technology and design products, which are economically feasible and socially relevant.
PEO3: Develop an attitude of lifelong learning for sustained career advancement and adapt to the
changing multidisciplinary profession.
PEO4: Demonstrate leadership qualities, effective communication skills, and to work in a team of
enterprising people in a multidisciplinary and multicultural environment with strong adherence to
professional ethics.

Table of content

Lab.no Experiment name Sessio Page


n no
1 Assembly level programming – Arithmetic operations 1 5
2 Assembly level programming – Loop operations 2 8
3 IO port programming using Keil 3 11
4 PWM waveform generation using keil 4
5 Delay using Timer using keil 5
6 I2C Interfacing using keil 6
7 DAC Interfacing using keil 7
8 Stepper motor interfacing using keil 8
9 ADC interfacing using mbed simulator 9
10 Binary counter using mbed simulator 10
11 PWM tone generation using mbed simulator 11
12 Interrupts and timers using mbed simulator 12
13 Touchscreen implementation using mbed simulator 13 45
14 Graphics display using mbed simulator 14 49
15 Miniproject 15

Laboratory Report Cover Sheet


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Assembly language program, simulation -1
Date of Conduction :
Date of Submission :

Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

REPORT Total 25
VERIFICATION
Staff Name :
Signature :

Experiment 1
Programming arm LPC 1768 – Addition – Immediate addressing
Aim: Program to Add two Hexadecimal Numbers.
Software Used: KEIL
Target Microcontroller: ARM LPC1768
Algorithm:
 Load your code in read only mode using the instruction AREA
PRAHELIKAEXPT1, CODE, READONLY.
 Write your code in an ENTRY and END block.
 Export your code module using the instruction EXPORT EXPTADD.
 Load value 4 into r0 and load value 5 into r1using MOV instruction.
 Add the values in r1 and r0 and store it in r2.  Use a stop loop and end the program.

Program:
AREA PRAHELIKAEXPT1, CODE, READONLY

ENTRY
EXPORT EXPTADD
EXPTADD
MOV r0,#4 ;load 4
into r0 MOV r1,#5
;load 5 into r1
ADD r2,r0,r1 ;add r0 to r1 and put the
result in r2 Stop B Stop
END ;end of program
Simulation Output:

Program:
AREA PRAHELIKAEXPT2, CODE, READONLY

ENTRY
EXPORT EXPTADDTHREE

EXPTADDTHREE
MOV r1,#Q ;load r1 with the constant Q
MOV r2,#R
MOV r3,#S
ADD r0,r1,r2
ADD r0,r0,r3
Stop B Stop
Q EQU 2 ;Equate the symbolic name Q to the value 2

R EQU 4 ;

S EQU 5 ;

END
Simulation Output:

Pre lab Questions:


1) ARM is grouped under Harvard architecture. Justify?
2) Name few arithmetic instructions supported by ARM
Post lab Questions:
3) How do you access memory in ARM? Identify the instructions in the above program
4) ARM is a RISC controller –Explain?

Result:
Addition of two Hexadecimal numbers is implemented in Keil software using the
ARM LPC 1768 Microcontroller.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Assembly language program, simulation 2
Date of Conduction :
Date of Submission :

Marks
Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 2

Assembly Language Programming – Loop Operations

Aim: To find factorial of a number, smallest/largest of an array of numbers, negative of an array of


numbers
Software Used: KEIL
Target Microcontroller: ARM LPC1768
Algorithm:

AREA FACTORIAL , CODE, READONLY


ENTRY ;Mark first instruction to execute
EXPORT __MAIN
__MAIN
MOV R0,#7 ; STORE FACTORIAL NUMBER IN R0
MOV R1,R0 ; MOVE THE SAME NUMBER IN R1
FACT
SUB R1, R1, #1 ; SUBTRACTION
CMP R1, #1 ; COMPARISON
BEQ STOP
MUL R3,R0,R1; ; MULTIPLICATION
MOV R0,R3 ; Result
BNE FACT ; BRANCH TO THE LOOP IF NOT EQUAL
STOP
END ;Mark end of file
AREA SMALLEST , CODE, READONLY
ENTRY ;Mark first instruction to execute
EXPORT __MAIN
__MAIN
MOV R5,#6 ; INTIALISE COUNTER TO 6(i.e. N=7)
LDR R1,=VALUE1 ; LOADS THE ADDRESS OF FIRST VALUE
LDR R2,[R1],#4 ; WORD ALIGN T0 ARRAY ELEMENT
LOOP
LDR R4,[R1],#4 ; WORD ALIGN T0 ARRAY ELEMENT
CMP R2,R4 ; COMPARE NUMBERS
BLS LOOP1 ; IF THE FIRST NUMBER IS > THEN GOTO LOOP1
MOV R2,R4 ; IF THE FIRST NUMBER IS < THEN MOV CONTENT R4 TO R2
LOOP1
SUB R5,R5,#1 ; DECREMENT COUNTER
CMP R5,#0 ; COMPARE COUNTER TO 0
BNE LOOP ; LOOP BACK TILL ARRAY ENDS
LDR R4,=RESULT ; LOADS THE ADDRESS OF RESULT
STR R2,[R4] ; STORES THE RESULT IN R1
;ARRAY OF 32 BIT NUMBERS(N=7)
VALUE1
DCD 0X44444444 ;
DCD 0X22222222 ;
DCD 0X11111111 ;
DCD 0X33333333 ;
DCD 0XAAAAAAAA ;
DCD 0X88888888 ;
DCD 0X99999999 ;
AREA DATA2,DATA,READWRITE ; TO STORE RESULT IN GIVEN
ADDRESS
RESULT DCD 0X0
END ; Mark end of file

iii) Negative numbers-finding


AREA NEGATIVE , CODE, READONLY
ENTRY ;Mark first instruction to execute
EXPORT __MAIN
__MAIN
MOV R5,#3 ; INTIALISE COUNTER TO 7(i.e. N=7)
MOV R2,#0 ; COUNTER
LDR R4,=VALUE ; LOADS THE ADDRESS OF FIRST VALUE
LOOP
LDR R1,[R4],#4 ; WORD ALIGN T0 ARRAY ELEMENT
AND R1,R1,#1<<31 ; TO CHECK NEGATIVE NUMBER
BHI FOUND ; IF THE GIVEN NUMBER IS NEGATIVE GOTO FOUND
B LOOP1; IF THE GIVEN NUMBER IS NOT NEGATIVE GOTO LOOP1
FOUND
ADD R2,R2,#1 ; INCREMENT THE COUNTER (NEGATIVE NUMBER)
B LOOP1 ; GOTO LOOP1
LOOP1
SUB R5,R5,#1 ; DECREMENT COUNTER
CMP R5,#0 ; COMPARE COUNTER TO 0
BNE LOOP ; LOOP BACK TILL ARRAY ENDS
;LDR R6,=RESULT;
;STR R2,[R6];
;ARRAY OF 32 BIT NUMBERS(N=7)
VALUE
DCD 0X12345678 ;
DCD 0X8D489867 ;
DCD 0XB1111111 ;
DCD 0XC3333333 ;
;DCD 0XE605546C ;
;DCD 0XAAAAAAAA;
;DCD 0X99999999 ;
;AREA DATA2,DATA,READWRITE ; TO STORE RESULT IN GIVEN ADDRESS
;RESULT
;DCD 0x0;
END ; Mark end of file

Pre lab Questions:


5) Draw the CPSR bit format
6) Name the different Processor modes supported by ARM
Post lab Questions:
7) MOV r7, r5, LSL #2 ; What is the result of this instruction?
8) STR r0, [r1]-Explain

Result:
Addition of three Hexadecimal numbers is implemented in Keil software using the
ARM LPC 1768 Microcontroller.

Laboratory Report Cover Sheet


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Marks
18ECE204J ARM based Embedded
Particulars Max. Marks System Design Lab
Obtained
Pre Lab
VI Semester, 2020-21 05
(Even Semester)

Name Post Lab 05 :


Register No. :
Lab Performance 10
Venue : Virtual Lab
Title of Lab Report 5 Experiment :
IO port programming
using Keil Total 25
Date of Conduction :
Date of Submission :
REPORT VERIFICATION

Staff Name :
Signature :

Experiment 3

IO port programming using Keil

Aim: To Flash leds using parallel GPIO port


Software Used: KEIL
Target Microcontroller: ARM LPC2148
Algorithm:
 Initialize the IODIR,IOSET and IOCLR registers
 Set the delay
 Initialize GPIO pins for output
 Check the output in GPIO interface window

Program:

#include <LPC21xx.H> /* LPC21xx definitions */


void wait (void) { /* wait function */
int d;
for (d = 0; d < 1000000; d++); /* only to delay for LED flashes */
}
int main (void) {
unsigned int i; /* LED var */
IODIR1 = 0x00FF0000; /* P1.16..23 defined as Outputs */
while (1) { /* Loop forever */
for (i = 1<<16; i < 1<<23; i <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
IOSET1 = i; /* Turn on LED */
wait (); /* call wait function */
IOCLR1 = i; /* Turn off LED */
}
for (i = 1<<23; i > 1<<16; i >>=1 ) { /* Blink LED 7,6,5,4,3,2,1 */
IOSET1 = i; /* Turn on LED */
wait (); /* call wait function */
IOCLR1 = i; /* Turn off LED */
}
}
}

Simulation Output:

Pre lab:
1. Mention the use of the utility Digitalout()
2. What is the significance of using while(1) in most of the programs?
3. Give two examples of a conditional loop statements.
4. What is size of character, integer, integer pointer, character pointer?
5. What is type casting ?

Post lab:
1. Write a mbed code to count a sequence of 4 bits using GPIO and LED1-4.
2. Explain the output of the partial code
while(i>0) { //start conditional loop
yourled = 1;
wait(0.2);
yourled = 0;
wait(0.2);
i = i-1;
}

3. State the significance of “=” and “= =” operator in mbed.

Result:
IO port programming is implemented in Keil software using the ARM LPC 1768
Microcontroller.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : PWM waveform generation using keil
Date of Conduction :
Date of Submission :

Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 4

PWM waveform generation using keil

Aim: To generate PWM waveform in LPC2148 controller using keil


Software Used: KEIL
Target Microcontroller: ARM LPC2148
Algorithm:
 Reset and disable PWM counter using PWMTCR
 Load prescale value according to need of application in the PWMPR
 Load PWMMR0 with a value corresponding to the time period of your PWM wave
 Load any one of the remaining six match registers (two of the remaining six match
registers for double edge controlled PWM) with the ON duration of the PWM cycle. (PWM
will be generated on PWM pin corresponding to the match register you load the value with).
 Load PWMMCR with a value based on the action to be taken in the event of a match
between match register and PWM timer counter.
 Enable PWM match latch for the match registers used with the help of PWMLER
 Select the type of PWM wave (single edge or double edge controlled) and which PWMs to
be enabled using PWMPCR
 Enable PWM and PWM counter using PWMTCR
Program:

#include <lpc214x.h>

__irq void PWM_ISR (void)


{
if ( PWMIR & 0x0001 ) /* If interrupt due to PWM0 */
{
PWMIR = 0x0001; /* Clear PWM0 interrupt */
}

if ( PWMIR & 0x0002 ) /* If interrupt due to PWM1 */


{
PWMIR = 0x0002; /* Clear PWM1 interrupt */
}

if ( PWMIR & 0x0004 ) /* If interrupt due to PWM2 */


{
PWMIR = 0x0004; /* Clear PWM2 interrupt */
}

if ( PWMIR & 0x0008 ) /* If interrupt due to PWM3 */


{
PWMIR = 0x0008; /* Clear PWM3 interrupt */
}
VICVectAddr = 0x00000000;
}

int main (void)


{
VPBDIV = 0x00000002; /*PCLK is ½ of CCLK*/
PINSEL0 = PINSEL0 | 0x00008008; /* Configure P0.1 and P0.7 as PWM3 and PWM2 respectively */
VICVectAddr0 = (unsigned) PWM_ISR; /* PWM ISR Address */
VICVectCntl0 = (0x00000020 | 8); /* Enable PWM IRQ slot */
VICIntEnable = VICIntEnable | 0x00000100; /* Enable PWM interrupt */
VICIntSelect = VICIntSelect | 0x00000000; /* PWM configured as IRQ */

// For PWM3 double edge


PWMTCR = 0x02; /* Reset and disable counter for PWM */
PWMPR = 0x1D; /* Prescale value for 1usec, Pclk=30MHz*/
PWMMR0 = 1000000; /* Time period of PWM wave, 100msec */
PWMMR2 = 40000; /* Rising edge of double edge controlled PWM */
PWMMR3 = 80000; /* Falling edge of double edge controlled PWM */
PWMMCR = 0x00000243; /* Reset and interrupt on MR0 match, interrupt on MR2 and MR3 match */
PWMLER = 0x0D; /* Latch enable for PWM3, PWM2 and PWM0 */
PWMPCR = 0x0C08; /* Enable PWM3, PWM2 and PWM0, double edge controlled PWM on PWM3 */
PWMTCR = 0x09; /* Enable PWM and counter */

while (1);
}

Simulation Output:

Pre lab:
1) What is GPIO direction register?
2) What is GPIO used for?
Post lab:
1) IO0DIR | = (1<<15); IO0SET | = (1<<15);
What does the above two lines indicate?
2) Which port is being used in this program? What is the change in code to select Port 0?
Result:

Laboratory Report Cover Sheet


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Delay using Timer using keil
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 5
Delay using Timer using keil

Aim: To implement Delay using Timer in LPC2148 controller using keil

Software Used: KEIL


Algorithm:
 PCLK = 30MHz
 Hence, we will load T0PR with a value 29, so that the TC will increment after every 30
PCLK rising edges.
 30MHz/30 = 1MHz, which gives 1µsec time.
 To get 100msec time, we will have to load T0MR with 100000 (1 µsec * 1000 = 1msec,
1msec * 100 = 100msec. Hence, 1000 * 100 = 100000)
 This will give us a delay of 100msec.
 Here we are using timer interrupt MR0. On each compare match between MR0 and TC, the
ISR for Timer0 will be executed where we are toggling the pin connected to the LED.
Program:
#include <lpc214x.h>
__irq void T0_ISR (void)
{
IO0PIN = ( IO0PIN ^ (0x00000100) ); /* Toggle P0.8 pin */
T0IR = ( T0IR | (0x01) );
VICVectAddr = 0x00;
}

int main (void)


{
VPBDIV = 0x00000002; /* For Pclk = 30MHz */
/* We have configured Cclk=60MHz. Above instruction makes Pclk = Cclk/2 = 30MHz */
PINSEL0 = PINSEL0 | 0x00000020; /* Configure P0.2 as Capture 0.0 */
IO0DIR = ( IO0DIR | (0x00000100) ); /* 8 P0.8-P0.15 as output pins for LED port */
IO0PIN = IO0PIN | 0x00000100; /* Writing 1 to LED pin P0.8 */
VICVectAddr0 = (unsigned) T0_ISR; /* T0 ISR Address */
VICVectCntl0 = 0x00000024; /* Enable T0 IRQ slot */
VICIntEnable = 0x00000010; /* Enable T0 interrupt */
VICIntSelect = 0x00000000; /* T0 configured as IRQ */
T0TCR = 0x02; /* Reset TC and PR */
T0CTCR = 0x00; /* Timer mode, increment on every rising edge */
T0PR = 0x1D; /* Load Pre-Scalar counter with 29 (0 to 29 = 30), so that timer counts every 1usec */
T0MR0 = 100000; /* Load timer counter for 100msec delay, 1usec*1000*100 */
T0MCR = 0x0003; /* Interrupt generate on match and reset timer */
T0TCR = 0x01; /* Enable timer */

while (1);
}
Simulation Output:

Pre lab Questions:


1) What is the maximum value, in decimal, that a 12-bit and a 24-bit counter can count
up to?
2) How can you classify tasks based on time?
Post lab Questions:
1) Give the difference between timeout and ticker function in timer application
2) A 4.0-MHz clock signal is connected to the inputs of a 12-bit and a 16-bit counter.
Each starts counting from zero. How long does it take before each it reaches its maximum value?

Result:
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : I2C Interfacing using keil
Date of Conduction :
Date of Submission :

Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 6
I2C Interfacing using keil
Aim: To perform I2C Interfacing in LPC2148 using keil

Software Used: KEIL

Program:
#include <lpc214x.h>
#include <stdint.h>
void I2C_INIT(void)
{
PINSEL0 = PINSEL0 | 0x00000050; /* Configure P0.2 and P0.3 as SCL0 and SDA0 respectively
*/
I2C0CONSET = 0x40; /* Enable I2C */
I2C0SCLL = 0x32; /* I2C data rate 300Khz and 50% duty cycle */
I2C0SCLH = 0x32; /* I2C data rate 300Khz and 50% duty cycle */
}
void I2C_START(void)
{
I2C0CONSET = 0x20; /* Set Start bit for Start condition */
while ( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x28; /* Clear Start bit and SI bit */
}
void I2C_WRITE( char data )
{
I2C0DAT = data; /* Load data to be written into the data register */
I2C0CONSET = 0x40; /* Enable I2C */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
}
unsigned char I2C_READ_ACK( void )
{
I2C0CONSET = 0x44; /* Enable I2C with Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x0C; /* Clear SI and Acknowledge bits */
return I2C0DAT; /* Return received data */
}
unsigned char I2C_READ_NACK( void )
{
I2C0CONSET = 0x40; /* Enable I2C without Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
return I2C0DAT; /* Return received data */
}
void I2C_MULTIREAD( char* arr , int bytes ) /* For reading multiple bytes at a time */
{
uint8_t i = 0;
while( ( bytes - 1 ) != 0 )
{
I2C0CONSET = 0x44; /* Enable I2C with Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x0C; /* Clear SI and Acknowledge bits */
*( arr + i ) = I2C0DAT ;
bytes--;
i++;
}
I2C0CONSET = 0x40; /* Enable I2C without Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
*( arr + i ) = I2C0DAT ;
}
void I2C_STOP( void )
{
I2C0CONSET = 0x50; /* Set Stop bit for Stop condition */
}
int main()
{
I2C_INIT();
I2C_START();
I2C_WRITE('c');
I2C_READ_ACK();
I2C_READ_NACK();
I2C_MULTIREAD("b",5);
I2C_STOP();
}

Simulation Output:
Pre lab Questions:
1) What are the limitations for the number of devices which can be connected to a single
SPI and I2C?
2) Draw up a table comparing the advantages and disadvantages for using SPI versus I2
C for serial communications.
Post Lab Questions:
1) An mbed configured as I2C Master is to be connected to three other mbeds, each configured as Slave.
Sketch a circuit which shows how this interconnection could be made. Explain your sketch.
2) An I2C link is running with a 500 kHz clock. How long does it take for a single
message containing one data byte to be transmitted?

Result:
Thus, the blinking of Led’s using switch is implemented successfully using
online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment :
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 7
DAC Interfacing using keil
Aim: To perform DAC Interfacing in LPC 2148 using keil
Software Used: KEIL
Algorithm:
 Here, we will load the DACR value with various values to generate a sine wave, triangular wave,
sawtooth wave, square wave and DC wave.
 4 switches are used as inputs on P0.8 (for sine wave), P0.9 (for triangular wave), P0.10 (for
sawtooth wave), and P0.11 (for square wave) pins.
 These pins are connected to 3.3 V through pull-up resistors. Only switch for P0.8 Switches are
connected in a similar manner to the other 3 pins as well.
 If we connect the DAC output pin P0.25 to an oscilloscope, we can observe the different waves.

Program:
#include <lpc214x.h>
#include <stdint.h>

void delay_ms(uint16_t j)
{
uint16_t x,i;
for(i=0;i<j;i++)
{
for(x=0; x<60000; x++); /* loop to generate 1 milisecond delay with Cclk = 60MHz */
}
}

int main (void)


{
uint16_t value;
uint8_t i;
uint16_t sin_wave[42] =
{ 512,591,665,742,808,873,926,968,998,1017,1023,1017,998,968,926,873,808,742,665,591,512,

436,359,282,216,211,151,97,55,25,6,0,6,25,55,97,151,211,216,282,359,436 };
i = 0;
PINSEL1 = 0x00080000; /* P0.25 as DAC output */
IO0DIR = ( IO0DIR & 0xFFFFF0FF ); /* Input pins for switch. P0.8 sine, P0.9 triangular, P0.10 sawtooth,
P0.11 square */

while(1)
{
if ( (IO0SET == 0x00000100)) /* If switch for sine wave is pressed */
{
while(i !=42)
{
value = sin_wave[i];
DACR = ( (1<<16) | (value<<6) );
delay_ms(1);
i++;
}
i = 0;
}
else if ((IO0SET==0x00000200)) /* If switch for triangular wave is pressed */
{
value = 0;
while ( value != 1023 )
{
DACR = ( (1<<16) | (value<<6) );
value++;
}
while ( value != 0 )
{
DACR = ( (1<<16) | (value<<6) );
value--;
}
}
else if ((IO0SET ==0x00000400)) /* If switch for sawtooth wave is pressed */
{

value = 0;
while ( value != 1023 )
{
DACR = ( (1<<16) | (value<<6) );
value++;
}
}
else if ((IO0SET ==0x00000800)) /* If switch for square wave is pressed */
{
value = 1023;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100);
value = 0;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100);
}
else /* If no switch is pressed, 3.3V DC */
{
value = 1023;
DACR = ( (1<<16) | (value<<6) );
}
}

}
Simulation Output:
Pre lab Questions:
1. What is the mbed’s DAC resolution and what is the smallest analog voltage step increase or
decrease which can be output from the mbed?
2. What is the output of the LPC1768 DAC, if its input digital word is a. 00 0000 1000
b. 0x80
c. 10 1000 1000?

Post lab Questions:


1. What output voltages will be read on a DVM while this program loop runs on the mbed?

while(1){
for (i=0;i&lt;1;i=i+0.2){ Aout=i;
wait(0.1);
}
}
2. The program in Question gives a crude saw tooth waveform. What is its period?

3. The PWM on an mbed is set up with these statements. What is the on time of the waveform?
PWM1.period(0.004); // set PWM period
PWM1=0.75; // set duty cycle
Result:
The DAC Interfacing in LPC 2148 using keil was performed and 4 waveforms were
generated.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment :
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 8
Stepper motor interfacing using keil
Aim: To perform Stepper motor interfacing in LPC 2148 using keil
Software Used: KEIL
Algorithm:
 Rotating stepper motor in clockwise and counter clockwise directions alternately.
 Here, we are using six wire unipolar stepper motor. Only four wires are required to control
this stepper motor. The two centre tap wires of the stepper motor are connected to 5V supply.
 ULN2003 driver is used to drive the stepper motor.
 Note : To find winding coils and their centre tap leads, measure resistance in between the
leads. From centre leads we will get half the resistance value as compared to the resistance
between winding ends.
Program:
#include &quot;mbed.h&quot;
#include &quot;C12832.h&quot;
#include &quot;Sht31.h&quot;
C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
Sht31 sht31(I2C_SDA, I2C_SCL);
DigitalOut led(LED1);
int main() {
printf(&quot;Set the temperature above 25 degrees to trigger the warning LED\n&quot;);
while (1) {
lcd.cls();
float temp = sht31.readTemperature();
float humidity = sht31.readHumidity();
lcd.locate(3, 3);
lcd.printf(&quot;Temperature: %.2f C&quot;, temp);
lcd.locate(3, 13);
lcd.printf(&quot;Humidity: %.2f %%&quot;, humidity);
// turn on LED if the temperature is above 25 degrees
led = temp &gt; 25.0f;
wait(0.5f);
}
}
Simulation Output:

Prelab
1. Draw the 4 possible rotor positions and the corresponding stator excitations in a stepper motor
2.   What is the specific property of the stepper motor which makes it compatible to interface with the
processor?
Post lab:
1. Modify the code to run in clockwise and anticlockwise alternatively?
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : ADC interfacing using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 9
ADC interfacing using mbed simulator

Aim: To explore mbed simulator – online and to perform A/D conversion, also view the
output in the serial output terminal
Software Used: mbed simulator
Algorithm:
1. Load the code in the simulator
2. Run the code
3. Set the temperature above 25 degrees to trigger the warning LED.
4. Set the temperature below 25 degrees to trigger the warning LED and cross-check
whether the output is correct
5. Save the output generated.
Program:
#include &quot;mbed.h&quot;
#include &quot;C12832.h&quot;
#include &quot;Sht31.h&quot;
C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
Sht31 sht31(I2C_SDA, I2C_SCL);
DigitalOut led(LED1);
int main() {
printf(&quot;Set the temperature above 25 degrees to trigger the warning LED\n&quot;);
while (1) {
lcd.cls();
float temp = sht31.readTemperature();
float humidity = sht31.readHumidity();
lcd.locate(3, 3);
lcd.printf(&quot;Temperature: %.2f C&quot;, temp);
lcd.locate(3, 13);
lcd.printf(&quot;Humidity: %.2f %%&quot;, humidity);
// turn on LED if the temperature is above 25 degrees
led = temp &gt; 25.0f;
wait(0.5f);
}
}
Simulation Output:
Pre lab Questions:
1. What do UART, CAN, I2C, and SPI stand for, and what do these mbed features have in common?
2. How many digital inputs are available on the mbed LPC1768?
Post Lab Questions:
1. A friend enters the code shown below into the mbed compiler, but when compiling, a number of
errors are flagged. Find and correct the faults.
#include mbed.h;
Digital Out myled(LED1);
int main() {
white(1)
{ myled = 1;
wait(0.2)
myled = 0;
wait(0.2);
}
2. Which mbed LPC1768 pins can be used for analog input and output?

Result:
Thus, the experiment A/D conversion is performed and the output is generated
successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Binary counter using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 10

Binary counter using mbed simulator


Aim: To explore mbed simulator – online and to perform Binary counter using leds
Software Used: mbed simulator
Algorithm:
1. Load the code in the simulator
2. Run the code
3. Set the counter and led interface.
4. Set the delay for on and off of leds
5. Save the output generated.

Program:

Lab 10a: Binary counter


#include "mbed.h"
 
//LED Output initializations
BusOut Bits(Bits(p5,p6,p7,p8); //LED outputs for counter
 
char bin_val = 0x00;
int main() {
    while(1) {
        //increment bin_val, resetting if 4-bit overflow condition occurs
        bin_val++;
        if(bin_val > 0x0F) 
        {
            bin_val = 0;
        }
        //Assign bin_val to led output
        Bits = bin_val;
        //wait 1 second
        wait(1);
    }
}
Simulation Output:
Lab 10b: Binary Up Counter With Leds
#include "mbed.h"
BusOut LEDS(p5,p6,p7,p8,p9,p10,p11,p12);
int main()
{
int CNT = 0; // CNT = 0
while(1) // Endless loop
{
LEDS = CNT; // Turn ON LED
wait(3.0); // Wait 1 second
CNT++; // Incfement CNT
if(CNT > 255)CNT = 0; // CNT back to 0
}}
Simulation Output:
Pre lab:
1.Mention the use of the utility Digitalout()
2.What is the significance of using while(1) in most of the programs?
3. Give two examples of a conditional loop statements.
4. What is size of character, integer, integer pointer, character pointer?
5. What is type casting ?

Post lab:
1. Write a mbed code to count a sequence of 4 bits using GPIO and LED1-4.
2. Explain the output of the partial code
while(i>0) { //start conditional loop
yourled = 1;
wait(0.2);
yourled = 0;
wait(0.2);
i = i-1;
}
3. State the significance of “=” and “= =” operator in mbed.

Result:
Thus, the experiment Binary counter is performed and the output is generated successfully using
online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : PWM tone generation using mbed simulator
ate of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 11

PWM tone generation using mbed simulator


Aim: To explore mbed simulator – online and to perform PWM tone generation
Software Used: mbed simulator
Algorithm:
1. Load the code in the simulator
2. Run the code
3. Set the frequencies to be palyed using speaker.
4. Set the delay for playing notes.
5. Save the output generated.
Program:
#include "mbed.h"
PwmOut speaker(p21);
void play_tone(float frequency, float volume, int interval, int rest) {
speaker.period(1.0 / frequency);
speaker = volume;
wait(interval);
speaker = 0.0;
wait(rest);
}

int main()
{
while(1) {
play_tone(200.0, 0.5, 1, 0);
play_tone(150.0, 0.5, 1, 0);
play_tone(125.0, 0.5, 1, 2);
}

Simulation Output:
Pre lab:
1. How to calculate the duty cycle of a PWM?
2. Define the relation between the duty cycle and period.
3. List any application of PWM in embedded system design
4. How to calculate the period of the PWM pulse?
5. How PWM is used to control motors?

Post Lab:
1. State any 3 standard function in mbed related to PWM
2. What will be the output of this program
#include "mbed.h"
PwmOut PWM1(p21)
int main()
{
PWM1.period(0.010);
PWM1=0.5;
}

Result:
Thus, the experiment PWM Sound generation is performed and the output is generated successfully
using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Interrupts and timers using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 12
Interrupts and timers using mbed simulator

Aim: To explore mbed simulator – online and to perform experiment on Interrupts,


Timers
Software Used: mbed simulator

Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated

Program:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);

Ticker t1;
Timeout t2;
InterruptIn btn(BUTTON1);

void blink_led1() {
printf("Ticker fired\n");
led1 = !led1;
}

void toggle_led2() {
printf("BUTTON1 fall invoked\n");
led2 = !led2;
}

void turn_led3_on() {
printf("Timeout fired\n");
led3 = 1;
}

int main() {
printf("Hello world!\n");
printf("LED1 will blink every second, LED3 will toggle after 2.5 seconds, LED2 can be toggled
through BUTTON1.\n");
printf("-----------------------------------\n\n");
t1.attach(callback(&blink_led1), 1.0f);
t2.attach(callback(&turn_led3_on), 2.5f);
btn.fall(callback(&toggle_led2));

wait_ms(osWaitForever);
}

Simulation Output:

Prelab
1. InterruptIn btn(BUTTON1) – comment
2. Define a ticker
3. Differentiate ticker and interrupt
4. What is meant by timeout condition
5. How many timers are available in ARM LPC?
Post lab:
1. Why the above program is using callback( )
2. What is the significance if attach function.
Result:
Thus, the experiment on Interrupts and Timers is performed and the output is generated
successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Touchscreen implementation using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 13

Touchscreen implementation using mbed simulator


Aim: To explore mbed simulator – online and to perform Touchscreen implementation
Software Used: mbed simulator

Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated.
Program:
/**

* This is a demo which uses the ST DISCO_F413ZH LCD and touch screen

* Contains a FRIDA FRD154BP2901 LCD display

* Code from https://os.mbed.com/teams/ST/code/DISCO_F413ZH-touch-screen-demo/?


platform=ST-Discovery-F413H

*/

#include "mbed.h"

#include "stm32f413h_discovery_ts.h"

#include "stm32f413h_discovery_lcd.h"

TS_StateTypeDef TS_State = { 0 };

int main() {

printf("Draw on the screen!\n");

BSP_LCD_Init();

/* Touchscreen initialization */

if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) {

printf("BSP_TS_Init error\n");

}
/* Clear the LCD */

BSP_LCD_Clear(LCD_COLOR_WHITE);

/* Set Touchscreen Demo1 description */

BSP_LCD_SetTextColor(LCD_COLOR_GREEN);

BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40);

BSP_LCD_SetTextColor(LCD_COLOR_BLACK);

BSP_LCD_SetBackColor(LCD_COLOR_GREEN);

BSP_LCD_SetFont(&Font16);

BSP_LCD_DisplayStringAt(0, 15, (uint8_t *)"Touch the screen", CENTER_MODE);

while (1) {

BSP_TS_GetState(&TS_State);

if(TS_State.touchDetected) {

/* One or dual touch have been detected */

/* Get X and Y position of the first touch post calibrated */

uint16_t x1 = TS_State.touchX[0];

uint16_t y1 = TS_State.touchY[0];

BSP_LCD_SetTextColor(LCD_COLOR_RED);

BSP_LCD_FillCircle(x1, y1, 5);

wait_ms(10);

Simulation Output:
Prelab:

1. What is the significance of include &quot;C12832.h.?

2. How direction of electric field influences the operation of LCD?

Post lab:

1. What is the output of the program

#define LCD_H

#include &quot;mbed.h&quot;

void toggle_enable(void);

void LCD_init(void);

void display_to_LCD(char value);

endif

Result:
Thus, the experiment Touch screen -Pixel Graphics- Implementing on LCD is performed and the
output is generated successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)

Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Graphics display using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05

Post Lab 05

Lab Performance 10

Lab Report 5

Total 25

REPORT VERIFICATION

Staff Name :
Signature :
Experiment 14

Graphics display using mbed simulator


Aim: To explore mbed simulator – online and to perform Graphics Display using LCD
Software Used: mbed simulator

Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated

Program:

#include "mbed.h"
#include "C12832.h"

C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);

// From https://os.mbed.com/users/dreschpe/code/Christmas-LCD

// graphics for the Christmas Demo


//
// Copyright (c) 2012 Peter Drescher - DC2PD
// made by hand - I have to look for a tool ;-)
// Released under the MIT License: http://mbed.org/license/mit

static char Tree[] = {


0x00, 0x00, 0x40, 0x00, 0x00, // XXXXXXXX, XXXXXXXX, X_XXXXXX, XXXXXXXX, XXXX
0x00, 0x00, 0x40, 0x00, 0x00, // XXXXXXXX, XXXXXXXX, X_XXXXXX, XXXXXXXX, XXXX
0x00, 0x00, 0xE0, 0x00, 0x00, // XXXXXXXX, XXXXXXXX, ___XXXXX, XXXXXXXX, XXXX
0x00, 0x01, 0xE0, 0x00, 0x00, // XXXXXXXX, XXXXXXX_, ___XXXXX, XXXXXXXX, XXXX
0x00, 0x03, 0xF0, 0x00, 0x00, // XXXXXXXX, XXXXXX__, ____XXXX, XXXXXXXX, XXXX
0x00, 0x07, 0xF8, 0x00, 0x00, // XXXXXXXX, XXXXX___, _____XXX, XXXXXXXX, XXXX
0x00, 0x07, 0x7C, 0x00, 0x00, // XXXXXXXX, XXXXX___, X_____XX, XXXXXXXX, XXXX
0x00, 0x0E, 0xBC, 0x00, 0x00, // XXXXXXXX, XXXX___X, _X____XX, XXXXXXXX, XXXX
0x00, 0x03, 0x78, 0x00, 0x00, // XXXXXXXX, XXXXXX__, X____XXX, XXXXXXXX, XXXX
0x00, 0x07, 0xfC, 0x00, 0x00, // XXXXXXXX, XXXXX___, ______XX, XXXXXXXX, XXXX
0x00, 0x0F, 0xfe, 0x00, 0x00, // XXXXXXXX, XXXX____, _______X, XXXXXXXX, XXXX
0x00, 0x1f, 0xff, 0x80, 0x00, // XXXXXXXX, XXX_____, ________, _XXXXXXX, XXXX
0x00, 0x7f, 0xff, 0xc0, 0x00, // XXXXXXXX, X_______, ________, __XXXXXX, XXXX
0x00, 0x0f, 0xdc, 0x00, 0x00, // XXXXXXXX, XXXX____, __X___XX, XXXXXXXX, XXXX
0x00, 0x3F, 0xaf, 0x00, 0x00, // XXXXXXXX, XX______, _X_X____, XXXXXXXX, XXXX
0x00, 0xff, 0xdf, 0xc0, 0x00, // XXXXXXXX, ________, __X_____, __XXXXXX, XXXX
0x01, 0xff, 0xff, 0xf0, 0x00, // XXXXXXX_, ________, ________, ____XXXX, XXXX
0x07, 0xf7, 0xff, 0xfc, 0x00, // XXXXX___, ____X___, ________, ______XX, XXXX
0x0f, 0xeb, 0xff, 0x7C, 0x00, // XXXX____, ___X_X__, ________, X_____XX, XXXX
0x03, 0xf7, 0xfe, 0xA0, 0x00, // XXXXXX__, ____X___, _______X, _X_XXXXX, XXXX
0x1f, 0xff, 0xff, 0x78, 0x00, // XXX_____, ________, ________, X____XXX, XXXX
0x7F, 0xff, 0xff, 0xfe, 0x00, // X_______, ________, ________, _______X, XXXX
0xff, 0xff, 0xff, 0xff, 0x80, // ________, ________, ________, ________, _XXX
0x0f, 0xff, 0xff, 0xf3, 0x80, // XXXX____, ________, ________, ____XX__, _XXX
0x00, 0x00, 0xc0, 0x01, 0x00, // XXXXXXXX, XXXXXXXX, __XXXXXX, XXXXXXX_, XXXX
0x00, 0x00, 0xc0, 0x02, 0x80, // XXXXXXXX, XXXXXXXX, __XXXXXX, XXXXXX_X, _XXX
0x00, 0x00, 0xc0, 0x01, 0x00, // XXXXXXXX, XXXXXXXX, __XXXXXX, XXXXXXX_, XXXX
0x00, 0x00, 0x00, 0x00, 0x00 // XXXXXXXX, XXXXXXXX, XXXXXXXX, XXXXXXXX, XXXX
};

Bitmap bitmTree = {
36, // XSize
28, // YSize
5, // Bytes in Line
Tree, // Pointer to picture data
};

static char Santa1[] = {


0x07, 0x00, 0x00, // XXXXX___, XXXXXXXX, X
0x05, 0x00, 0x00, // XXXXX_X_, XXXXXXXX, X
0x07, 0x00, 0x00, // XXXXX___, XXXXXXXX, X
0x07, 0xC0, 0x00, // XXXXX___, __XXXXXX, X
0x07, 0xE0, 0x00, // XXXXX___, ___XXXXX, X
0x07, 0xF0, 0x00, // XXXXX___, ____XXXX, X
0x0F, 0xF8, 0x00, // XXXX____, _____XXX, X
0x1c, 0x08, 0x00, // XXX___XX, XXXX_XXX, X
0x08, 0xA8, 0x00, // XXXX_XXX, _X_X_XXX, X
0x0C, 0x08, 0x00, // XXXX__XX, XXXX_XXX, X
0x06, 0x28, 0x00, // XXXXX__X, XX_X_XXX, X
0x03, 0x98, 0x00, // XXXXXX__, _XX__XXX, X
0x0d, 0xfe, 0x00, // XXXX__X_, _______X, X
0x78, 0xf3, 0x00, // X____XXX, ____XX__, X
0x50, 0x61, 0x80, // X_X_XXXX, X__XXXX_, _
0xd0, 0x60, 0x80, // __X_XXXX, X__XXXXX, _
0x90, 0x00, 0x80, // _XX_XXXX, XXXXXXXX, _
0x90, 0x01, 0x00, // _XX_XXXX, XXXXXXX_, X
0x90, 0x01, 0x00, // _XX_XXXX, XXXXXXX_, X
0xd0, 0x03, 0x00, // __X_XXXX, XXXXXX__, X
0x70, 0x02, 0x00, // X___XXXX, XXXXXX_X, X
0x1f, 0xfc, 0x00, // XXX_____, ______XX, X
0x07, 0xfc, 0x00, // XXXXX___, ______XX, X
0x07, 0x0c, 0x00, // XXXXX___, XXXX__XX, X
0x07, 0x0c, 0x00, // XXXXX___, XXXX__XX, X
0x07, 0xbc, 0x00, // XXXXX___, _X____XX, X
0x03, 0x38, 0x00, // XXXXXX__, XX___XXX, X
0x00, 0x20, 0x00, // XXXXXXXX, XX_XXXXX, X
};

Bitmap bitmSan1 = {
17, // XSize
28, // YSize
3, // Bytes in Line
Santa1 , // Pointer to picture data
};

static char Santa2[] = {


0x03, 0x80, 0x00 , // XXXXXX__, _XXXXXXX, X
0x02, 0x80, 0x00 , // XXXXXX_X, _XXXXXXX, X
0x07, 0x00, 0x00 , // XXXXX___, XXXXXXXX, X
0x07, 0xc0, 0x00 , // XXXXX___, __XXXXXX, X
0x07, 0xe0, 0x00 , // XXXXX___, ___XXXXX, X
0x07, 0xf0, 0x00 , // XXXXX___, ____XXXX, X
0x0f, 0xf8, 0x00 , // XXXX____, _____XXX, X
0x1c, 0x08, 0x00 , // XXX___XX, XXXX_XXX, X
0x08, 0xa8, 0x00 , // XXXX_XXX, _X_X_XXX, X
0x0c, 0x08, 0x00 , // XXXX__XX, XXXX_XXX, X
0x06, 0x28, 0x00 , // XXXXX__X, XX_X_XXX, X
0x03, 0x98, 0x00 , // XXXXXX__, _XX__XXX, X
0x0d, 0xf6, 0x00 , // XXXX__X_, ____X__X, X
0x78, 0xf3, 0x00 , // X____XXX, ____XX__, X
0x50, 0x61, 0x80 , // X_X_XXXX, X__XXXX_, _
0xd0, 0x60, 0x80 , // __X_XXXX, X__XXXXX, _
0x90, 0x00, 0x80 , // _XX_XXXX, XXXXXXXX, _
0x90, 0x01, 0x00 , // _XX_XXXX, XXXXXXX_, X
0x90, 0x01, 0x00 , // _XX_XXXX, XXXXXXX_, X
0xd0, 0x03, 0x00 , // __X_XXXX, XXXXXX__, X
0x70, 0x02, 0x00 , // X___XXXX, XXXXXX_X, X
0x1f, 0xfc, 0x00 , // XXX_____, ______XX, X
0x07, 0xdc, 0x00 , // XXXXX___, __X___XX, X
0x07, 0x0e, 0x00 , // XXXXX___, XXXX___X, X
0x07, 0x0e, 0x00 , // XXXXX___, XXXX___X, X
0x0e, 0x0f, 0x80 , // XXXX___X, XXXX____, _
0x08, 0x00, 0x00 , // XXXX_XXX, XXXXXXXX, X
0x00, 0x00, 0x00 , // XXXXXXXX, XXXXXXXX, X
};

Bitmap bitmSan2 = {
17, // XSize
28, // YSize
3, // Bytes in Line
Santa2 , // Pointer to picture data
};

static char Santa3[] = {


0x1c, 0x00, 0x00 , //XXX___XX, XXXXXXXX, X
0x17, 0x00, 0x00 , //XXX_X___, XXXXXXXX, X
0x1f, 0xc0, 0x00 , //XXX_____, __XXXXXX, X
0x07, 0xe0, 0x00 , //XXXXX___, ___XXXXX, X
0x07, 0xf0, 0x00 , //XXXXX___, ____XXXX, X
0x0f, 0xf8, 0x00 , //XXXX____, _____XXX, X
0x1c, 0x08, 0x00 , //XXX___XX, XXXX_XXX, X
0x08, 0xa8, 0x00 , //XXXX_XXX, _X_X_XXX, X
0x0c, 0x08, 0x00 , //XXXX__XX, XXXX_XXX, X
0x06, 0x28, 0x00 , //XXXXX__X, XX_X_XXX, X
0x03, 0x98, 0x00 , //XXXXXX__, _XX__XXX, X
0x0d, 0xf6, 0x00 , //XXXX__X_, ____X__X, X
0x78, 0xf3, 0x00 , //X____XXX, ____XX__, X
0x50, 0xe1, 0x80 , //X_X_XXXX, ___XXXX_, _
0xd0, 0x60, 0x80 , //__X_XXXX, X__XXXXX, _
0x90, 0x00, 0x80 , //_XX_XXXX, XXXXXXXX, _
0x90, 0x01, 0x00 , //_XX_XXXX, XXXXXXX_, X
0x90, 0x01, 0x00 , //_XX_XXXX, XXXXXXX_, X
0x20, 0x03, 0x00 , //__X_XXXX, XXXXXX__, X
0x70, 0x02, 0x00 , //X___XXXX, XXXXXX_X, X
0x1f, 0xfc, 0x00 , //XXX_____, ______XX, X
0x07, 0xdc, 0x00 , //XXXXX___, __X___XX, X
0x07, 0x0e, 0x00 , //XXXXX___, XXXX___X, X
0x07, 0x0e, 0x00 , //XXXXX___, XXXX___X, X
0x07, 0xcf, 0x80 , //XXXXX___, __XX____, _
0x00, 0x00, 0x00 , //XXXXXXXX, XXXXXXXX, X
};

Bitmap bitmSan3 = {
17, // XSize
26, // YSize
3, // Bytes in Line
Santa3 , // Pointer to picture data
};

int main() {
printf("Demo by Peter Dresche\n");
printf("https://os.mbed.com/users/dreschpe/code/Christmas-LCD\n");
int i, s;
lcd.cls();
// lcd.set_font((unsigned char*) Arial_9);
s = 3;
lcd.print_bm(bitmTree, 95, 0); // print chistmas tree
lcd.copy_to_lcd();
lcd.setmode(XOR); // XOR - a second print will erase
for (i = -15; i < 75;) {
lcd.print_bm(bitmSan1, i, 2);
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan1, i, 2); // erase
i = i + s;
lcd.print_bm(bitmSan2, i, 2); // print next
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan2, i, 2); // erase
i = i + s;
lcd.print_bm(bitmSan3, i, 2); // print next
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan3, i, 2); // erase
i = i + s;
}
lcd.print_bm(bitmSan3, i, 2);
lcd.set_auto_up(0);
for (i = -20; i < 5; i++) { // scrolling text
lcd.locate(5, i);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();
lcd.locate(5, i);
wait(0.2);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();
i = i + 1;
}
lcd.locate(5, i);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();

printf("Done!\n");
}

Simulation Output:

Prelab:

1. Mention the operating voltage of LCD.

2. What is meant by backplane in LCD displays?

3. What is meant by contrast in LCD?

Post lab:

1. Write a program to print “HELLO” in the LCD screen

Result:
Thus, the experiment Graphics Display using LCD is performed and the output is generated
successfully using online mbed simulator.

You might also like