ARM 7 LPC 2148 lecture
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
7,087
On Slideshare
5,479
From Embeds
1,608
Number of Embeds
37

Actions

Shares
Downloads
318
Comments
1
Likes
2

Embeds 1,608

http://www.discovermechatronics.blogspot.in 563
http://discovermechatronics.blogspot.in 461
http://discovermechatronics.blogspot.com 217
http://www.discovermechatronics.blogspot.com 213
http://discovermechatronics.blogspot.ru 20
http://www.discovermechatronics.blogspot.co.uk 15
http://discovermechatronics.blogspot.de 14
http://www.discovermechatronics.blogspot.ca 11
http://www.discovermechatronics.blogspot.de 10
http://www.discovermechatronics.blogspot.ae 8
http://discovermechatronics.blogspot.com.es 7
http://www.discovermechatronics.blogspot.com.br 6
http://www.discovermechatronics.blogspot.ro 6
http://www.discovermechatronics.blogspot.kr 5
http://www.discovermechatronics.blogspot.com.es 5
http://discovermechatronics.blogspot.com.ar 5
http://www.discovermechatronics.blogspot.tw 5
http://www.discovermechatronics.blogspot.mx 4
http://www.discovermechatronics.blogspot.fr 3
http://www.discovermechatronics.blogspot.co.nz 3
http://discovermechatronics.blogspot.kr 2
http://www.discovermechatronics.blogspot.jp 2
http://discovermechatronics.blogsopt.com 2
http://discovermechatronics.blogspot.se 2
http://www.discovermechatronics.blogspot.ru 2
http://www.discovermechatronics.blogspot.nl 2
http://discovermechatronics.blogspot.ro 2
http://www.discovermechatronics.blogspot.sg 2
http://discovermechatronics.blogspot.co.uk 2
http://discovermechatronics.blogspot.com.br 2
http://www.google.co.in 1
http://discovermechatronics.blogspot.sg 1
http://www.discovermechatronics.blogspot.hk 1
http://discovermechatronics.blogspot.hk 1
http://www.discovermechatronics.blogspot.pt 1
http://www.discovermechatronics.blogspot.se 1
http://discovermechatronics.blogspot.jp 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. GPIO Seven Segment Display InterfaceProgram Statement: Interface four seven segment displays on GPIO’s of ARM7 LPC2148 and write aC 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 BlockProblem Statement: Write a program to send a string on serial port UART0 of LPC2148 continuouslyat 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 FIFOs 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 0xc0void 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