I am currently trying to control two seven segment displays from the same 7 pins (P0.0 - P0.6) of an ARM 7 micro-controller. I am first testing this on Proteus simulation software.
I am following the schematic from this 8051 multiplexing tutorial, however my 7 segment displays are connected from Port 0.0 to Port 0.6 and the two controlling transistors are connected at P0.7 and P0.8.
I am pretty sure that the seven-segment display and transistors from my simulation are connected correctly, and that the problem is arising from the following code. I have also tested my code to make sure I am displaying the correct numbers and that the transistor pins are configured as required.
The problem I am encountering is that both digits are being printed on both displays, instead of the first display showing 1
and the second display showing 2
.
#include <LPC21xx.h>
#define a 0x00000001
#define b 0x00000002
#define c 0x00000004
#define d 0x00000008
#define e 0x00000010
#define f 0x00000020
#define g 0x00000040
#define T2 0x00000080
#define T1 0x00000100
void small_delay (void);
int main (void)
{
PINSEL0 = 0; //Set P0.0 - P0.15 as GPIOS
PINSEL1 = 0; //Set P0.16 - P0.31 as GPIOS
IO0DIR = 0xFFFFFFFF; //Set all port0 pins as outputs
while (1){
IO0SET = e; //displaying number 1
IO0SET = f; //displaying number 1
IO0SET = T1; //switching on first display
small_delay(); //calling short delay
IO0CLR = T1; //clearing first display
IO0SET = a; //displaying number 2
IO0SET = b; //displaying number 2
IO0SET = g; //displaying number 2
IO0SET = e; //displaying number 2
IO0SET = d; //displaying number 2
IO0SET = T2; //switching on first display
small_delay(); //calling small delay
IO0CLR = T2; //clearing second display
}
}
void small_delay (void)
{
unsigned int i, j;
for (i=0; i<10; i++)
{
//do nothing
}
}
This is what I am trying to achieve with the above code:
- Send data
1
to both displays. - Enabling left seven segment by using
IO0SET = T1;
- Calling a short
delay
. - Disabling left seven segment by using
IO0CLR = T1;
- Sending data
2
to both displays. - Enabling right seven segment by using
IO0SET = T2;
- Calling a short
delay
. - Disabling right seven segment by using
IO0CLR = T2;
- Repeat.
Are there any flaws in this logic ? Any suggestions/ideas regarding what I am doing wrong in my coding would be greatly appreciated.