This article is a four seven segment digit with dot multiplexing example.
Please read them: seven segment display , seven segment display
The program receives a float number throught hyperterminal, separates the integer and fractional part using modf() mathematical function included
at <math.h> ,finds the four digits that will be presented at the four displays,
finds the corresponding integers that will turn ON the right segments of the displays and finally finds the right place of the "dot" segment.
Unwanted zeros in front of the number are not displayed.
For example 3 is displayed as 3.000 and not as 0003. A 3.45 is displayed as 3.450
To turn ON the right segments we use a lookup table:
unsigned int table[11]={0X7E,0X30,0X6D,0X79,0X33,0X5B,0X5F,0X70,0X7F,0X7B};
To multiplex the four digits we use a timer T2 interrupt at 0.5 sec. It is a slow multiplexing rate , used for educational purpose only.In practice you have to decrease it using DAVE. The multiplexing code is in GPT1.C file.
The four displays are common cathode displays conected at P1H (multiplexed at
P1H3,P1H2,P1H1,P1H0 pins of the parallel port) and the corresponding data are at
P1L (P1L6,P1L5,P1L4,P1L3,P1L2,P1L1,P1L0 pins , "dot" at P1L7 pin of the port).
The C code The result
So, run the code at simulator and watch the displays "dancing".
Debuger C code The result
* The i counter included at interrupt C code is not needed.
|