[SOLVED] 7 segment interfacing with LPC2138 code not working

Status
Not open for further replies.

Ravindrakant Jha

Junior Member level 2
Joined
Nov 2, 2014
Messages
24
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Location
India
Activity points
274

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <LPC213X.H>
#define a (1<<16)
#define b (1<<17)
#define c (1<<18)
#define d (1<<19)
#define e (1<<20)
#define f (1<<21)
#define g (1<<22)
#define SSD  (a|b|c|d|e|f|g)
#define ZERO (a|b|c|d|e|f) 
#define ONE  (b|c)
#define TWO  (a|b|g|e|d)
#define THREE (a|b|g|c|d)
#define FOUR  (b|c|f|g)
#define FIVE  (a|c|d|f|g)
#define SIX   (a|c|d|e|f|g)
#define SEVEN (a|b|c)
#define EIGHT (a|b|c|d|e|f|g)
#define NINE  (a|b|c|f|g)
void delay(void)
{
   unsigned int i;
   for(i=0;i<50000;i++);
}
 
void ssd_display(int val)
{
  IOCLR1|=SSD;
  if(val==0)
   {
     IOSET1|=ZERO;
   }
   else if(val==1)
   {
      IOSET1|=ONE;
   } 
   else if(val==2)
   {
     IOSET1|=TWO;
   }
   else if(val==3)
   {
     IOSET1|=THREE;
   }
   else if(val==4)
   {
     IOSET1|=FOUR;
   }
   else if(val==5)
   {
     IOSET1|=FIVE;
   }
   else if(val==6)
   {
     IOSET1|=SIX;
   }
   else if(val==7)
   {
     IOSET1|=SEVEN;
   }
   else if(val==8)
   {
     IOSET1|=EIGHT;
   }
   else if(val==9)
   {
     IOSET1|=NINE;
   }
 
} 
int main()
{
    int i;
  IODIR1|=0Xffffffff|SSD;
  while(1)
  {
    for(i=1;i<10;i++)
    {
      ssd_display(i);
      delay();
    }
  }
}

 

I feel summoned to declaim forum rules

It's also a bit insolent to drop some lines of code without a question.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…