timer or clock for 7 segment display

Thread Starter

antiantianti

Joined Aug 4, 2016
45
Hi
This is a question of basics
In the problem I have to solve this problem : 2 displays have to be on at the same time and for this we have to use timers so that the two displays will be cyclically on and off . I tried putting them both on and its works so I dont get why we must use timers to do this (multiplex) .
also can you help me write the code in c please (generic 8051)


THX
 

Thread Starter

antiantianti

Joined Aug 4, 2016
45
it is . I spent a lot of time working alone unfortunately didnt make a lot of progress .
I tried using a timer
here is my code
C:
typedef unsigned char INT8U;
typedef unsigned int INT16U;
data INT8U z1  _at_ 0x0;
data INT8U bzz _at_ 0x2;
sbit P2_0=P2^0;
sbit P2_1=P2^1;
void T0Delay(void);
void main()
{
    Init_Device();
    Init_Vars();
while (1) //repeat forever
{
    P2_0=0x00;
T0Delay();

P2_1=0x00;
    T0Delay();
}
}
    void T0Delay()
        {

TMOD=0x01;     // timer 0, mode 1
TL0=0x06;      // load TL0
TH0=0xe3;      // load TH0
TR0=1;         // turn on Timer0

while (TF0==0);           // wait for TF0 to roll over

TR0=0;      // turn off timer
TF0=0;      // clear TF0
}
Well When the program arrives to TF0 he seem to be doing this forever and doesnt overflow so my prgram stops here please help Im not making a lot of progress and seem to be wasting a lot of time
 

shteii01

Joined Feb 19, 2010
4,644
8051 has 4 ports (32 pins). Normally one port is occupied by clock crystal and stuff. One port might have serial communication attached to it. That leaves you with two empty ports (16 pins). Attach one 7 segment to first empty port. Attach another 7 segment to second empty port.

Don't forget to use current limiting resistors for each led segment.
 
Top