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.

[SOLVED] multiplexing of 7 segment display with 8051

Status
Not open for further replies.

rohini.embsystem

Newbie level 4
Joined
May 19, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pune
Activity points
1,328
hi everybody.i hv a problem with my code.it is a counter prgrm.i hv 2 calculate like 99,98.........00 bt it is giving o/p like 9(1st display),then it goes off n then 9 on 2nd display.m using ATMEL 89C51 controller n using keil compiler.my code is


#include<reg51.h>
sfr disp_val=0X90;
sbit ds1=P2^0;
sbit ds2=P2^1;
void system_init(void);
void delay(void);
void dec_seg_1(void);
void dec_seg_2(void);
void dec_both_seg(void);
void disp(void);
void segment(void);
unsigned int val_1,val_2,z,cnt;
unsigned char arr[]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F};

void main(void)
{
cnt=0;
TMOD=0X01;
TL0=0x00;// Timer value for interrupt is 1ms
TH0=0x00;
IE=0X82;
TR0=1;
while(1)
{
system_init();
}
}

void system_init(void)
{

val_1=9;
val_2=9;
segment();
}

void segment(void)
{
do
{
disp();
dec_seg_2();
}while(cnt>0);
}

void disp(void)
{
ds1=0;
ds2=1;
z=val_1;
disp_val=arr[z];
delay();
ds1=1;
ds2=0;
z=val_2;
disp_val=arr[z];
delay();
}

void dec_seg_2(void)
{
val_2--;
if(val_2<0)
dec_seg_1();
}

void dec_seg_1(void)
{
val_2=9;
val_1--;
if(val_1<0)
dec_both_seg();
}

void dec_both_seg(void)
{
ds1=ds2=0;
z=0;
disp_val=arr[z];
main();
}

void delay(void)
{
//for(i=0;i<=40;i++)
//TMOD=0x10;
TH1=0x4B;
TL1=0xFD;
TR1=1;
(while TF1==0);
TR1=0;
TF1=0;
}
/*int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
*/
}

void timer0() interrupt 1
{
cnt++;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top