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.

7 Segment Display C Code Help

Status
Not open for further replies.
Joined
Dec 4, 2012
Messages
4,280
Helped
822
Reputation
1,654
Reaction score
791
Trophy points
1,393
Location
Bangalore, India
Activity points
0
I have written a 7 Segment display Code but it is not working. Can somebody find what is the error?

I am using PIC16F887 at 4 MHz and MAX7219 7 Segment Driver. I am driving 8 X 7-Segments. My code displays any integer value. If integer value is passed it is converted to String and displayed on 7-Segment(s).

mikroC PRO PIC 6.0.1 Code v1.0.0


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
//**********************************************************************
//  C-Programm for driving a MAX7219
//  a 8 digit number is printed in a string (sprintf)
//  and then send to the MAX7219
//**********************************************************************
 
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(unsigned long int);
//**********************************************************************
void main (void)
{       TRISB = 0x00;
        PORTB = 0x00;
        
        MAX7219init();
        Display(47110815);//my_weird_number
        
        while(1){Display(47110815);} //my_weird_number}
}
//**********************************************************************
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
//**********************************************************************
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
//**********************************************************************
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
//**********************************************************************
void Display (unsigned long int My_number)
{
        unsigned char i,string[8];
        LongToStr(My_number, string);
        for (i=0;i<8;i++)
        {
                if (string[i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[i] <= 0x39)
                                Send7219(i+1,Font_B[string[i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[i] - 0x57]);//A-F
        }
}




Here is new code. It is now displaying the digits but only one or two digits gets displayed and diplay flickers.

mikroC PRO PIC 6.0.1 Code v1.0.1


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
84
85
86
87
88
89
90
91
92
93
94
//**********************************************************************
//  C-Programm for driving a MAX7219
//  a 8 digit number is printed in a string (sprintf)
//  and then send to the MAX7219
//**********************************************************************
 
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(unsigned long int);
//**********************************************************************
void main (void)
{       TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;
        
        MAX7219init();
        Display(47110815);//my_weird_number
        
        while(1){;}//Display(47110815);} //my_weird_number}
}
//**********************************************************************
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
//**********************************************************************
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
//**********************************************************************
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
//**********************************************************************
void Display (unsigned long int My_number)
{
        unsigned char i,string[8];
        
        LongToStr(My_number, string);
 
        for (i=0;i<8;i++)
        {
                if (string[i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[i] <= 0x39)
                                Send7219(i+1,Font_B[string[i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[i] - 0x57]);//A-F
        }
}
 
 
 
 
//**********************************************************************

 

Attachments

  • 7 Seg.rar
    93.5 KB · Views: 92
Last edited:

Left click within the text "LongToStr" and press F1 key to get help on this function.

You will see that you have not met the requirements of the LongToStr function.
 
Thanks hexreader. I fixed the code but it still doesn't display digits properly. Here is my new code.

mikroC PRO PIC 6.0.1 Code v1.0.2


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
84
85
86
87
88
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
unsigned long value;
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(unsigned long int);
 
void main (void){
        TRISA = 0xFF;
        TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;
        
        MAX7219init();
        Display(47110815);//my_weird_number
        
        if(1014500<=value<=1014999);
        
        while(1){;}//Display(47110815);} //my_weird_number}
}
 
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
 
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
 
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
 
void Display (unsigned long int My_number)
{
        unsigned char i,str[17], string[8];
        
        LongToStr(My_number, str);
        for(i = 3;i<11;i++)string[i-3] = str[i];
        for (i=0;i<8;i++)
        {
                if (string[i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[i] <= 0x39)
                                Send7219(i+1,Font_B[string[i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[i] - 0x57]);//A-F
        }
}

 

Works perfectly on my hardware (EasyPIC6). Steady 8 digit number on display.

...Except that the number is printed backwards - 51801174, but this would be an easy bug to fix.

Maybe you have a hardware problem?
 
What Clock did you use? I am using 4 MHz and I see only 2 or 3 digits and it flickers.

Can you please test this new code hexreader on hardware?

mikroC PRO PIC 6.0.1 Code v1.0.3


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
84
85
86
87
88
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
unsigned long value;
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(unsigned long int);
 
void main (void){
        TRISA = 0xFF;
        TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;
        
        MAX7219init();
        Display(47110815);//my_weird_number
        
        if(1014500<=value<=1014999);
        
        while(1){;}//Display(47110815);} //my_weird_number}
}
 
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
 
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
 
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
 
void Display (unsigned long int My_number)
{
        unsigned char i,str[17], string[8];
        
        LongToStr(My_number, str);
        for(i = 3;i<11;i++)string[i-3] = str[i];
        for (i=8;i>0;i--)
        {
                if (string[i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[i] <= 0x39)
                                Send7219(i+1,Font_B[string[i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[i] - 0x57]);//A-F
        }
}

 
Last edited:

What Clock did you use? I am using 4 MHz and I see only 2 or 3 digits and it flickers.
4MHz crystal and exactly the same project settings as you have in your .rar project file.

Seeing 8 digits (reversed) and a perfectly steady, bright, display.
 
How to fix the reverse?

There are many ways. I did it this way:

Code:
void Display (unsigned long int My_number)
{
        unsigned char i,str[17], string[8];

        LongToStr(My_number, str);
        for(i = 3;i<11;i++)string[i-3] = str[i];
        for (i=0;i<8;i++)
        {
                if (string[7-i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[7-i] <= 0x39)
                                Send7219(i+1,Font_B[string[7-i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[7-i] - 0x57]);//A-F
        }
}
And tell me how to display floating point values.
I have never used floating point with PICs, but I imagine you would use the FloatToStr library function.

I imagine that displaying a floating point number on only 8 digits will look terrible though. I would have thought a ten digit display would be a minimum to be usable, ideally 12 digits or more.
 
Last edited:
What driver should I use to drive 15 digits? Any MAX Driver you know? What changes in the code have to be made in display routine? Just add check for '.' and display display '.' depending on the position of '.'?

The changes you made works great. Thank you very much. Here is my new code.

mikroC PRO PIC 6.0.1 Code v1.0.4


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
84
85
86
87
88
89
90
91
92
/*
8 X 7-Segment Drived C Code
Author Jayanth Devarayanadurga
Data    12/05/2013
*/
 
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
unsigned long value;
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(unsigned long int);
 
void main (void){
        TRISA = 0xFF;
        TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;
 
        MAX7219init();
        Display(47110815);//my_weird_number
 
        while(1){;}//Display(47110815);} //my_weird_number}
}
 
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
 
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
 
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
 
void Display (unsigned long int My_number)
{
        unsigned char i,str[17], string[8];
 
        LongToStr(My_number, str);
        for(i = 3;i<11;i++)string[i-3] = str[i];
        for (i=0;i<8;i++)
        {
                if (string[7-i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);          //send MAX7219 " " to MAX7219
                else    if (string[7-i] <= 0x39)
                                Send7219(i+1,Font_B[string[7-i] - 0x30]);//0-9
                                else
                                Send7219(i+1,Font_B[string[7-i] - 0x57]);//A-F
        }
}



90936d1368336188-7-seg.jpg


@hexreader

see this https://embedded-lab.com/blog/?p=4935

It tells that bit 7 has to be set to 1 to get DP (decimal Point). How to do that in my code?
 

Attachments

  • 7 Seg.jpg
    7 Seg.jpg
    277.4 KB · Views: 194
Last edited:

What driver should I use to drive 15 digits?
2 x 7219?

Any MAX Driver you know?
7219 is the only driver I have ever used.

What changes in the code have to be made in display routine? Just add check for '.' and display display '.' depending on the position of '.'?
You will also need to provide a space for exponent sign.

e.g. -1.23456-03 (note how this is 10 characters, if you use the 7-seg dot to save a character)

If 4 digit mantissa is acceptable (e.g. -1.234-03) then 8 digits may be enough.
 
Last edited:
My value will be something like this 999.999e+/-9. It will be only positive values.
Then 8 digits may be enough.

What about MAX6954 and 6955? They use SPI and I2C.
I can not comment - never used either.

- - - Updated - - -

If you are building your own display, then you could make a 9 digit display and still use a single 7219.

Digit 8 will only show a minus sign, or be blank, so you could wire up only the centre segment and drive it in place of the decimal-point for digit 9.

Less versatile, but possibly another option....
 
I have made 16 7-Segment digits Display using two 7219 (Cascaded). What should I change in my code to display floating point numbers. I want to display like 0.0123456 that is I dont want to use e-9 or something like that. I need only three digits before and 3 digits after decimal point.

Edit: hexreader, I am attaching my project files and posting my new code. I have a bug in the code. Can you please fix it. I have made changes for the previous working code so that it displays floating point values but it is displaying wrong values. If I send 230.23445 it displays 2300.2344

mikroC PRO PIC 6.0.1 Code v 1.0.5


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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
8 X 7-Segment Drived C Code
Author Jayanth Devarayanadurga
Data    12/05/2013
*/
 
#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit
 
const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};
 
unsigned long value;
unsigned char dpset = 0;
 
void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(float);
 
void main (void){
        TRISA = 0xFF;
        TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;
 
        MAX7219init();
        Display(230.14592);//my_weird_number
 
        while(1){;}//Display(47110815);} //my_weird_number}
}
 
void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}
 
void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}
 
void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;
 
        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}
 
void Display (float My_number)
{
        unsigned char i, string[23];
 
        FloatToStr(My_number, string);
        string[8] = '\0';
 
        for (i=0;i<8;i++)
        {
                if (string[7-i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);
                          //send MAX7219 " " to MAX7219
 
                else if ((string[7-i] <= 0x39))
                      Send7219(i+1,(Font_B[string[7-i] - 0x30]));//0-9
                else
                      Send7219(i+1,(Font_B[string[7-i] - 0x57]));//A-F
                      
                if (string[7-i] == '.')//0x20 is ASCII " "
 
                        if (string[7-(i+1)] <= 0x39)
                              Send7219(i+1,(Font_B[string[7-(i+1)] - 0x30]) | (0b10000000));//0-9
                        else
                              Send7219(i+1,(Font_B[string[7-(i+1)] - 0x57]) | (0b10000000));//A-F
        }
}



90945d1368361035-7-seg-dp.png
 

Attachments

  • 7 Seg dp.rar
    64.7 KB · Views: 91
  • 7 Seg dp.png
    7 Seg dp.png
    34 KB · Views: 150
Last edited:

Here is some (terrible) code that seems to work for the two numbers tested:

Code:
/*
8 X 7-Segment Drived C Code
Author Jayanth Devarayanadurga
Data    12/05/2013
*/

#define Data7219 RB0_bit
#define Load7219 RB1_bit
#define Clk7219 RB2_bit

const unsigned char Font_B[16]=
{
        0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,
        0x7f,0x7b,0x77,0x1f,0x4e,0x3d,0x4f,0x47
};

unsigned long value;
unsigned char dpset = 0;

void Send7219 (char,char);
void Send7219byte(char);
void MAX7219init();
void Display(float);

void main (void){
        TRISA = 0xFF;
        TRISB = 0x00;
        PORTB = 0x00;
        ANSEL = 0x00;
        ANSELH = 0x00;
        ADCON1 = 0x00;
        CM1CON0 = 0x00;
        CM2CON0 = 0x00;

        MAX7219init();
        Display(230.14592);                  //my_weird_number
        //Display(123.45678);                    //much easier to work with

        while(1){;}//Display(47110815);} //my_weird_number}
}

void MAX7219init()
{
        Data7219 =0;
        Load7219 =0;
        Clk7219 = 0;
        Send7219(0x09,0x00);//Decode Mode
        Send7219(0x0A,0x05);//Brightness
        Send7219(0x0B,0x07);//Scan limit
        Send7219(0x0C,0x01);
        Send7219(0x0F,0x00);
}

void Send7219 (char Digit,char Data)
{
        Send7219byte(Digit);
        Send7219byte(Data);
        Data7219=0;
        Load7219=1;
        Load7219=0;
}

void Send7219byte (char byte)
{
unsigned char I;
        for(I=0;I<8;I++)
        {
        if (byte & 0x80)
                Data7219=1;
        else
                Data7219=0;

        Clk7219=1;
        byte<<=1;
        Clk7219=0;
        }
}

void Display (float My_number)
{
        unsigned char dispskip;         // add 1 if "." found within string
        unsigned char i, string[23];

        FloatToStr(My_number, string);
        string[9] = 0;                // null terminate
        string[8] = 0x20;             // FloatToString returns 7 characters + ".", so blank the 9th

        dispskip = 8;                 // initialise
        for (i=0;i<8;i++)
        {
                if (string[dispskip-i] == 0x20)//0x20 is ASCII " "
                Send7219(i+1,0);
                          //send MAX7219 " " to MAX7219

                else if ((string[dispskip-i] <= 0x39))
                      Send7219(i+1,(Font_B[string[dispskip-i] - 0x30]));//0-9
                else
                      Send7219(i+1,(Font_B[string[dispskip-i] - 0x57]));//A-F
                      
                if (string[dispskip-i] == '.'){//0x20 is ASCII " "
                        dispskip = 7;                                                 //
                        if (string[dispskip-i] <= 0x39)
                              Send7219(i+1,(Font_B[string[dispskip-i] - 0x30]) | (0b10000000));//0-9
                        else
                              Send7219(i+1,(Font_B[string[dispskip-i] - 0x57]) | (0b10000000));//A-F
                }
        }
}
I would suggest that it is time to start over with a simpler algorithm that is easier to understand and thus simpler to debug.

Maybe break the code into smaller, simpler, more logical modules that can be tested independently.

Good luck..
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top