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
Zynq architecture
Nguyen Le Hung Nguyen
Ā 
PPTX
Serial connectors, Protocols , USB (universal serial bus)
A. Shamel
Ā 
PPTX
Arithmetic instructions
Robert Almazan
Ā 
PPTX
ARM stacks, subroutines, Cortex M3, LPC 214X
Karthik Vivek
Ā 
PPTX
486 or 80486 DX Architecture
Muthusamy Arumugam
Ā 
PPT
finite word length effects.ppt
manojn87
Ā 
PPT
AMBA.ppt
Anbuselvi Mathivanan
Ā 
PPTX
advancsed microprocessor and interfacing
@zenafaris91
Ā 
Zynq architecture
Nguyen Le Hung Nguyen
Ā 
Serial connectors, Protocols , USB (universal serial bus)
A. Shamel
Ā 
Arithmetic instructions
Robert Almazan
Ā 
ARM stacks, subroutines, Cortex M3, LPC 214X
Karthik Vivek
Ā 
486 or 80486 DX Architecture
Muthusamy Arumugam
Ā 
finite word length effects.ppt
manojn87
Ā 
advancsed microprocessor and interfacing
@zenafaris91
Ā 

What's hot (20)

PPTX
x86 architecture
i i
Ā 
PPTX
decade counter
Abhishek Sainkar
Ā 
PPT
Rotate instructions
Dr. Girish GS
Ā 
PPTX
Timer counter in arm7(lpc2148)
Aarav Soni
Ā 
PPT
Arm instruction set
Ravi Babu
Ā 
PPT
I2C
rchovatiya
Ā 
PPT
ARM Architecture
Kshitij Gorde
Ā 
PDF
PCI Express Verification using Reference Modeling
DVClub
Ā 
PPTX
Digital electronics nandhini kusuma
kusuma11
Ā 
PDF
Introduction to arm architecture
Zakaria Gomaa
Ā 
PPT
AMBA_APB_pst
Bynaboina Krishna
Ā 
PDF
Nec 602 unit ii Random Variables and Random process
Dr Naim R Kidwai
Ā 
PDF
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
Ā 
PDF
Router 1X3 – RTL Design and Verification
IJERD Editor
Ā 
PPTX
Addressing Modes Of 8086
Ikhlas Rahman
Ā 
DOCX
Arm7 Interfacing examples
Dr.YNM
Ā 
PPTX
Amba axi 29 3_2015
kiemnhatminh
Ā 
PPTX
RTL-Design for beginners
Dr.YNM
Ā 
PDF
Performance Comparison Between x86 and ARM Assembly
Manasa K
Ā 
x86 architecture
i i
Ā 
decade counter
Abhishek Sainkar
Ā 
Rotate instructions
Dr. Girish GS
Ā 
Timer counter in arm7(lpc2148)
Aarav Soni
Ā 
Arm instruction set
Ravi Babu
Ā 
I2C
rchovatiya
Ā 
ARM Architecture
Kshitij Gorde
Ā 
PCI Express Verification using Reference Modeling
DVClub
Ā 
Digital electronics nandhini kusuma
kusuma11
Ā 
Introduction to arm architecture
Zakaria Gomaa
Ā 
AMBA_APB_pst
Bynaboina Krishna
Ā 
Nec 602 unit ii Random Variables and Random process
Dr Naim R Kidwai
Ā 
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
Ā 
Router 1X3 – RTL Design and Verification
IJERD Editor
Ā 
Addressing Modes Of 8086
Ikhlas Rahman
Ā 
Arm7 Interfacing examples
Dr.YNM
Ā 
Amba axi 29 3_2015
kiemnhatminh
Ā 
RTL-Design for beginners
Dr.YNM
Ā 
Performance Comparison Between x86 and ARM Assembly
Manasa K
Ā 
Ad

Similar to ARM 7 LPC 2148 lecture (20)

TXT
Senior design project code for PPG
FrankDin1
Ā 
DOCX
Include
Munkherdene Batsaikhan
Ā 
PDF
include ltiostreamgt include ltstringgt include .pdf
contact32
Ā 
DOC
Tai lieu ky thuat lap trinh
Hồ TrĘ°į»ng
Ā 
PDF
Rkf
faintcardy
Ā 
PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
forwardcom41
Ā 
PPTX
A scrupulous code review - 15 bugs in C++ code
PVS-Studio LLC
Ā 
PDF
C Code and the Art of Obfuscation
guest9006ab
Ā 
DOCX
codings related to avr micro controller
Syed Ghufran Hassan
Ā 
PDF
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
UVCE
Ā 
TXT
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Karthik Rathinavel
Ā 
PDF
I have written the code but cannot complete the assignment please help.pdf
shreeaadithyaacellso
Ā 
PPTX
Bank management system project in c++ with graphics
Vtech Academy of Computers
Ā 
PDF
Python From Scratch (1).pdf
NeerajChauhan697157
Ā 
PPTX
2- Dimensional Arrays
Education Front
Ā 
KEY
Haskellć§å­¦ć¶é–¢ę•°åž‹čØ€čŖž
ikdysfm
Ā 
PPTX
C++ Lambda and concurrency
ėŖ…ģ‹  ź¹€
Ā 
TXT
Teste
Nando Mathias
Ā 
PDF
Microsoft Word Hw#1
kkkseld
Ā 
DOCX
question 1a) tm=0.0089b) the tab.docx
makdul
Ā 
Senior design project code for PPG
FrankDin1
Ā 
include ltiostreamgt include ltstringgt include .pdf
contact32
Ā 
Tai lieu ky thuat lap trinh
Hồ TrĘ°į»ng
Ā 
Rkf
faintcardy
Ā 
Combine the keypad and LCD codes in compliance to the following requ.pdf
forwardcom41
Ā 
A scrupulous code review - 15 bugs in C++ code
PVS-Studio LLC
Ā 
C Code and the Art of Obfuscation
guest9006ab
Ā 
codings related to avr micro controller
Syed Ghufran Hassan
Ā 
Lab programs FOR 8TH SEM EC SUBJECT BY LOHITH KUMAR |11GUEE6018
UVCE
Ā 
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Karthik Rathinavel
Ā 
I have written the code but cannot complete the assignment please help.pdf
shreeaadithyaacellso
Ā 
Bank management system project in c++ with graphics
Vtech Academy of Computers
Ā 
Python From Scratch (1).pdf
NeerajChauhan697157
Ā 
2- Dimensional Arrays
Education Front
Ā 
Haskellć§å­¦ć¶é–¢ę•°åž‹čØ€čŖž
ikdysfm
Ā 
C++ Lambda and concurrency
ėŖ…ģ‹  ź¹€
Ā 
Teste
Nando Mathias
Ā 
Microsoft Word Hw#1
kkkseld
Ā 
question 1a) tm=0.0089b) the tab.docx
makdul
Ā 
Ad

More from anishgoel (20)

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

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
Ā 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
Ā 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
Ā 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
Ā 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
Ā 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
Ā 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
Ā 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
PDF
The Future of Artificial Intelligence (AI)
Mukul
Ā 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
Ā 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
Ā 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
Ā 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
Ā 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
Ā 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
Ā 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
Ā 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
Ā 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
Ā 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
Brief History of Internet - Early Days of Internet
sutharharshit158
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
Ā 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
The Future of Artificial Intelligence (AI)
Mukul
Ā 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
Ā 
The Future of AI & Machine Learning.pptx
pritsen4700
Ā 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
Ā 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 

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