Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need code for interfacing 4 digit 7segment display with ARM 2138

Status
Not open for further replies.

veleda

Newbie level 2
Joined
Dec 10, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
Hi Alll...
I am new to this forum.
I am trying to interface 4 digit 7segment display with AM lpc2138
I am working in Keil uVision4.
I wrote the code...but its not working.
Can anybody help me?
I am writing my code here.
Plz plz plz..help me asap.

#include<lpc21xx.h>

void wait(void)
{
int d;
for(d=0;d<100000;d++)
}

#define SEGCONTROL 0x000000F0 //port0 pin 0.4 to 0.7 selected
#define SEG1 0x00000010 //1ST DIGIT out of 4 dig 7 segment selected
#define SEG2 0x00000020
#define SEG3 0x00000040
#define SEG4 0x00000080

#define SEGDATA 0xFF000000 //port1 pin 1.24 to 1.31 selected
#define ONE 0xF9000000
#define TWO 0XA4000000
#define THREE 0xB0000000
#define FOUR 0X99000000
#define FIVE 0X92000000
#define SIX 0x82000000
#define SEVEN 0xF8000000
#define EIGHT 0x80000000
#define NINE 0x90000000
#define ZERO 0xC0000000

void DispData(int data);
void DispON(int ID);
void ShowDigit(int r, int i);
void DispOFF(int ID);

int main(void)
{

int count;

IODIR0 = SEGCONTROL;
IODIR1 = SEGDATA;

DispON(SEG1);
DispData(ONE);

for(count = 0; count<=9999; count++)
{
IOCLR1 = 1234;
DispData(count);
wait();
wait();
wait();
}

void DispON(int ID)
{
IOSET0 = ID;
wait();
IOCLR0 = ID;
IOSET0 = 0Xfffffffff & (~ID);
}
void DispOFF(int ID)
{ IOSET1 = SAGDATA;
}

void DispData(int data)
{
int r, int i;
for(i= 0; i<4; i++)
{
if(data>9)
{
r = data%10;
ShowDigit(r,i);
data = data/10;
}
else if(data >= 0 && data<=9)
{
ShowDigit(r,i);
i=4;
}
wait();
wait();
}

void ShowDigit(int r, int i)
{
switch(i)
{
case 0: DispON(SEG1);
break;
.
.
.
case 3: DispON(SEG3);
break;
}
wait();

switch(r)
{
case 0: IOSET1 = ZERO;
wait();
IOCLR1 =ZERO;
break;
.
.
.
.
case 9: IOSET1 = NINE;
wait();
IOCLR1 =NINE;
break;
}
wait();
switch(i)
{
case 0: DispOFF(SEG1);
break;
.
.
.
case 3: DispOFF(SEG3);
break;
}

}

plz tell me where i am going wrong in this code.
and if possible plz give me code so that i can see where i went wrong?
 

he i dont get time for reading your post
here are some codes which i worked on the 8051...
i have sent data serially through shift register and this code is also written for that diagram
 

Attachments

  • untitled.JPG
    untitled.JPG
    42.8 KB · Views: 106
  • ssd.rar
    791 bytes · Views: 78

alright...
but plz hav a look in my code.
It would be verynice if u correct me in that code..so that from next time onwords i wont do that mistake.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top