SlideShare a Scribd company logo
GPIO Seven Segment Display Interface
Program Statement: Interface four seven segment displays on GPIO’s of ARM7 LPC2148 and write a
C code to display count 0000 to 9999 on them with appropriate delay.

Solution:

# include<lpc214x.h>

void delay(void);

main()

{
         char num[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x67};
         char t,j,h,i,k;
         int m;
         char num1[] = {0x00,0x00,0x00,0x00};
         char num2[] = {0x70,0xb0,0xd0,0xe0};
         int y;
         IO0DIR = 0x00ffff00;
         for(y=1;y<10000;y++)
         {
                  if(y<10)
                  {
                           num1[3]=num[0];
                           num1[2]=num[0];
                           num1[1]=num[0];
                           num1[0]=num[y];
                  }

                else if (y>= 10 && y <100)
                {
                          num1[3]=num[0];
                          num1[2]=num[0];
                          num1[1]=num[y/10];
                          num1[0]=num[y-((y/10)*10)];
                }

                else if (y>= 100 && y <1000)
                {
                          num1[3]=num[0];
                          num1[2]=num[y/100];
                          num1[1]=num[(y-((y/100)*100))/10];
                          num1[0]=num[y-((y/100)*100)-(((y-((y/100)*100))/10)*10)];
                }

                else
                {
                       num1[3]=num[y/1000];
                       num1[2]=num[(y-((y/1000)*1000))/100];

LPC2148 Lecture Notes ENT505                 Prof. Anish Goel                            Page 1
num1[1]=num[(y-((y/1000)*1000)-((y/100)*100))/10];
                         num1[0]=num[y-((y/1000)*1000)-((y/100)*100)-((y/10)*10)];
                  }



         for(m=0;m<2;m++)
         {
                for(t=0;t<4;t++)
                {
                         IO0SET = (num1[t] << 16) | (num2[t] << 8);
                         delay();
                         IO0CLR = (num1[t] << 16) | (num2[t] << 8);
                         delay();
                }
         }
}
}

void delay(void)
{
        long int t;
        for(t=0;t<30000;t++);
}



Serial Interface UART Block
Problem Statement: Write a program to send a string on serial port UART0 of LPC2148 continuously
at 9600 baud.

Solution Clue:

#include"LPC214x.h"

void Initialize(void);

/* Macro Definitions */
#define TEMT (1<<6);
#define LINE_FEED 0xA;
#define CARRIAGE_RET 0xD;

/************************* MAIN *************************/
int main()
{
int i;
char c[]="Philips LPC";
Initialize();
/* Print forever */
while(1)
{
i=0;

LPC2148 Lecture Notes ENT505                 Prof. Anish Goel                             Page 2
/* Keep Transmitting until Null character('0') is reached */
while(c[i])
{
U0THR=c[i];
i++;
}
U0THR=LINE_FEED;
U0THR = CARRIAGE_RET;

/* Wait till U0THR and U0TSR are both empty */

while(!(U0LSR & (1<<6)))

{}
}
}
/*************** System Initialization ***************/
void Initialize()
{
/* Initialize Pin Select Block for Tx and Rx */
PINSEL0=0x5;
/* Enable FIFO's and reset them */
U0FCR=0x7;
/* Set DLAB and word length set to 8bits */
U0LCR=0x83;
/* Baud rate set to 9600 */
U0DLL=0x10;
U0DLM=0x0;
/* Clear DLAB */
U0LCR=0x3;
}
/*********************************************************/

16x2 LCD Program Hint
#include<lpc214x.h>
#include<STDIO.H>

#define line0 0x80
#define line1 0xc0


void delay(void);
void delay1(void);
void comdisp(char);
void comdata(char);
void display(char*,char);

main()
{
         unsigned int x;

LPC2148 Lecture Notes ENT505                   Prof. Anish Goel   Page 3
IO0DIR=0xffffffff;
       comdisp(0x38);
       comdisp(0xf);
       comdisp(0x6);
       comdisp(0x87);
       comdisp(0x1);
       display("LPC 2148",line0);
       display("ARM 7",line1+3);

}

void display(char *dat,char addr)
{
        char count;
        comdisp(addr);
        for(count=0;dat[count];count++)
        {
                 comdata(dat[count]);
        }
}
void comdisp(char lcddata)
{
        char word = 0xf9;
        char word1 = 0xf1;
        IO0SET = (lcddata<<8) | word;
        delay1();
        IO0SET = IO0SET && word1;
        delay();
        IO0CLR = 0x0000;
}
void comdata(char lcddata)
{
        char word = 0xf3;
        char word1 = 0xfb;
        IO0SET = (lcddata<<8) | word;
        delay1();
        IO0CLR = ~(IO0SET && word1);
        delay();
        IO0CLR = 0xffff;
}
void delay(void)
{
        int t;
        for(t=0;t<1;t++);
}
void delay1(void)
{
        int t;
        for(t=0;t<1;t++);
}



LPC2148 Lecture Notes ENT505              Prof. Anish Goel   Page 4

More Related Content

PDF
Question paper with solution the 8051 microcontroller based embedded systems...
PPTX
8255 PPI
PPT
Interfacing rs232
PDF
Seven segment interfacing with 8051.pdf
PPTX
microcontroller vs microprocessor
DOCX
Lambda design rule
PPTX
Interfacing technique with 8085- ADC[0808]
DOCX
ARM lab programs
Question paper with solution the 8051 microcontroller based embedded systems...
8255 PPI
Interfacing rs232
Seven segment interfacing with 8051.pdf
microcontroller vs microprocessor
Lambda design rule
Interfacing technique with 8085- ADC[0808]
ARM lab programs

What's hot (20)

PDF
Pic microcontroller architecture
PDF
ARM CORTEX M3 PPT
PPT
ARDUINO AND ITS PIN CONFIGURATION
DOC
PIC MICROCONTROLLERS -CLASS NOTES
PPTX
8051 timer counter
PPTX
Interfacing Stepper motor with 8051
PPT
Interrupts for PIC18
PPTX
Arm cortex-m3 by-joe_bungo_arm
PPTX
Arithmetic and Logic instructions in Embedded C
PDF
8155 PPI
PDF
Memory interfacing of microcontroller 8051
PPTX
MODEL TRAIN CONTROLLER.pptx
PPTX
Microcontroller presentation
DOCX
Arm7 Interfacing examples
PPTX
Hardware Software Codesign
DOC
8051 Microcontroller Notes
PDF
Unit 1 intro-embedded
PPTX
LPC 2148 ARM MICROCONTROLLER
PDF
EMI EMC RE CE
PPTX
DMA and DMA controller
Pic microcontroller architecture
ARM CORTEX M3 PPT
ARDUINO AND ITS PIN CONFIGURATION
PIC MICROCONTROLLERS -CLASS NOTES
8051 timer counter
Interfacing Stepper motor with 8051
Interrupts for PIC18
Arm cortex-m3 by-joe_bungo_arm
Arithmetic and Logic instructions in Embedded C
8155 PPI
Memory interfacing of microcontroller 8051
MODEL TRAIN CONTROLLER.pptx
Microcontroller presentation
Arm7 Interfacing examples
Hardware Software Codesign
8051 Microcontroller Notes
Unit 1 intro-embedded
LPC 2148 ARM MICROCONTROLLER
EMI EMC RE CE
DMA and DMA controller
Ad

Similar to ARM 7 LPC 2148 lecture (20)

DOCX
7segment scetch
TXT
Sine Wave Generator with controllable frequency displayed on a seven segment ...
PDF
optimization c code on blackfin
TXT
Chuongtrinh led ma trix
PPTX
Temperature sensor with a led matrix display (arduino controlled)
DOC
optimization process on compiler
DOCX
Lab. Programs in C
PDF
Arduino reference
PDF
Floating point basicsThe core idea of floating-point representatio.pdf
PDF
04 2 오버플로 상수 매크로
DOCX
#include #include #include using namespace std;v
PDF
Arduino coding class
DOC
SE Computer, Programming Laboratory(210251) University of Pune
PPTX
R tist
PDF
SOLUTION MANUAL OF COMPUTER ORGANIZATION BY CARL HAMACHER, ZVONKO VRANESIC & ...
PDF
Exploitation
PPTX
Ee2356 lab manual
7segment scetch
Sine Wave Generator with controllable frequency displayed on a seven segment ...
optimization c code on blackfin
Chuongtrinh led ma trix
Temperature sensor with a led matrix display (arduino controlled)
optimization process on compiler
Lab. Programs in C
Arduino reference
Floating point basicsThe core idea of floating-point representatio.pdf
04 2 오버플로 상수 매크로
#include #include #include using namespace std;v
Arduino coding class
SE Computer, Programming Laboratory(210251) University of Pune
R tist
SOLUTION MANUAL OF COMPUTER ORGANIZATION BY CARL HAMACHER, ZVONKO VRANESIC & ...
Exploitation
Ee2356 lab manual
Ad

More from anishgoel (20)

PDF
Computer Organization
PDF
Learning vhdl by examples
PDF
Dot matrix module interface wit Raspberry Pi
PDF
Input interface with Raspberry pi
PDF
Learning Python for Raspberry Pi
PDF
Raspberry Pi
PDF
learning vhdl by examples
PDF
Digital System Design Basics
PPTX
digital design of communication systems
PPTX
Rtos concepts
PDF
8051 Microcontroller Timer
PDF
8051 Microcontroller I/O ports
PDF
Serial Communication Interfaces
PDF
Embedded systems ppt iv part d
PDF
Embedded systems ppt iv part c
PDF
Embedded systems ppt iv part b
PDF
Embedded systems ppt ii
PDF
Embedded systems ppt iii
PDF
Embedded systems ppt iv part a
PDF
Embedded systems ppt i
Computer Organization
Learning vhdl by examples
Dot matrix module interface wit Raspberry Pi
Input interface with Raspberry pi
Learning Python for Raspberry Pi
Raspberry Pi
learning vhdl by examples
Digital System Design Basics
digital design of communication systems
Rtos concepts
8051 Microcontroller Timer
8051 Microcontroller I/O ports
Serial Communication Interfaces
Embedded systems ppt iv part d
Embedded systems ppt iv part c
Embedded systems ppt iv part b
Embedded systems ppt ii
Embedded systems ppt iii
Embedded systems ppt iv part a
Embedded systems ppt i

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Spectroscopy.pptx food analysis technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?
SOPHOS-XG Firewall Administrator PPT.pptx
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Empathic Computing: Creating Shared Understanding
Spectroscopy.pptx food analysis technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Network Security Unit 5.pdf for BCA BBA.
A comparative analysis of optical character recognition models for extracting...
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

ARM 7 LPC 2148 lecture

  • 1. GPIO Seven Segment Display Interface Program Statement: Interface four seven segment displays on GPIO’s of ARM7 LPC2148 and write a C code to display count 0000 to 9999 on them with appropriate delay. Solution: # include<lpc214x.h> void delay(void); main() { char num[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x67}; char t,j,h,i,k; int m; char num1[] = {0x00,0x00,0x00,0x00}; char num2[] = {0x70,0xb0,0xd0,0xe0}; int y; IO0DIR = 0x00ffff00; for(y=1;y<10000;y++) { if(y<10) { num1[3]=num[0]; num1[2]=num[0]; num1[1]=num[0]; num1[0]=num[y]; } else if (y>= 10 && y <100) { num1[3]=num[0]; num1[2]=num[0]; num1[1]=num[y/10]; num1[0]=num[y-((y/10)*10)]; } else if (y>= 100 && y <1000) { num1[3]=num[0]; num1[2]=num[y/100]; num1[1]=num[(y-((y/100)*100))/10]; num1[0]=num[y-((y/100)*100)-(((y-((y/100)*100))/10)*10)]; } else { num1[3]=num[y/1000]; num1[2]=num[(y-((y/1000)*1000))/100]; LPC2148 Lecture Notes ENT505 Prof. Anish Goel Page 1
  • 2. num1[1]=num[(y-((y/1000)*1000)-((y/100)*100))/10]; num1[0]=num[y-((y/1000)*1000)-((y/100)*100)-((y/10)*10)]; } for(m=0;m<2;m++) { for(t=0;t<4;t++) { IO0SET = (num1[t] << 16) | (num2[t] << 8); delay(); IO0CLR = (num1[t] << 16) | (num2[t] << 8); delay(); } } } } void delay(void) { long int t; for(t=0;t<30000;t++); } Serial Interface UART Block Problem Statement: Write a program to send a string on serial port UART0 of LPC2148 continuously at 9600 baud. Solution Clue: #include"LPC214x.h" void Initialize(void); /* Macro Definitions */ #define TEMT (1<<6); #define LINE_FEED 0xA; #define CARRIAGE_RET 0xD; /************************* MAIN *************************/ int main() { int i; char c[]="Philips LPC"; Initialize(); /* Print forever */ while(1) { i=0; LPC2148 Lecture Notes ENT505 Prof. Anish Goel Page 2
  • 3. /* Keep Transmitting until Null character('0') is reached */ while(c[i]) { U0THR=c[i]; i++; } U0THR=LINE_FEED; U0THR = CARRIAGE_RET; /* Wait till U0THR and U0TSR are both empty */ while(!(U0LSR & (1<<6))) {} } } /*************** System Initialization ***************/ void Initialize() { /* Initialize Pin Select Block for Tx and Rx */ PINSEL0=0x5; /* Enable FIFO's and reset them */ U0FCR=0x7; /* Set DLAB and word length set to 8bits */ U0LCR=0x83; /* Baud rate set to 9600 */ U0DLL=0x10; U0DLM=0x0; /* Clear DLAB */ U0LCR=0x3; } /*********************************************************/ 16x2 LCD Program Hint #include<lpc214x.h> #include<STDIO.H> #define line0 0x80 #define line1 0xc0 void delay(void); void delay1(void); void comdisp(char); void comdata(char); void display(char*,char); main() { unsigned int x; LPC2148 Lecture Notes ENT505 Prof. Anish Goel Page 3
  • 4. IO0DIR=0xffffffff; comdisp(0x38); comdisp(0xf); comdisp(0x6); comdisp(0x87); comdisp(0x1); display("LPC 2148",line0); display("ARM 7",line1+3); } void display(char *dat,char addr) { char count; comdisp(addr); for(count=0;dat[count];count++) { comdata(dat[count]); } } void comdisp(char lcddata) { char word = 0xf9; char word1 = 0xf1; IO0SET = (lcddata<<8) | word; delay1(); IO0SET = IO0SET && word1; delay(); IO0CLR = 0x0000; } void comdata(char lcddata) { char word = 0xf3; char word1 = 0xfb; IO0SET = (lcddata<<8) | word; delay1(); IO0CLR = ~(IO0SET && word1); delay(); IO0CLR = 0xffff; } void delay(void) { int t; for(t=0;t<1;t++); } void delay1(void) { int t; for(t=0;t<1;t++); } LPC2148 Lecture Notes ENT505 Prof. Anish Goel Page 4