No schematic, no code...
Are you serious ?
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
| static void Send16bits (unsigned short output)
{
unsigned char i;
for (i=16; i>0; i--)
{
unsigned short mask = 1 << (i - 1); // calculate bitmask
SERCLK = LOW;
// Send one bit on the data pin
if (output & mask)
LED_DATA = HIGH;
else
LED_DATA = LOW;
SERCLK = HIGH;
SERCLK = LOW;
}
}
// Take a reg numer and data and send to the max7219
static void MAX7219Send (unsigned char reg_number, unsigned char dataout)
{
LOAD_DATA = 1;
Send16bits((reg_number << 8) + dataout); // send 16 bits ( reg number + dataout )
LOAD_DATA = 0;
LOAD_DATA = 1;
}
void init_MAX7219_NEW(void){
// set decode mode
MAX7219Send(0x09, 0xFF);
// set intensity
MAX7219Send(0x0A, 0x0F);
// set scan limit 0-7
MAX7219Send(0x0B, 0x05); // 6 digits
// set for normal operation
MAX7219Send(0x0C, 0x01);
// NO TEST
MAX7219Send(0x0F, 0x00);
// clear MAX7219 all zeros
// BCD mode all off otherwise
for(int i = 1; i <= 6; i++){
MAX7219Send(i, 0x00);
}
}
int decToBcd(int val){
// Convert normal decimal numbers to binary coded decimal
return ( (val/10*16) + (val%10) );
}
int bcdToDec(int val){
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
} |
When running "for" loop, instead of clear the LED digits, it shows the numbers that we supplied.
Code C - [expand] |
1
2
3
4
5
6
| main(){
unsigned char bcd;
bcd = decToBcd(1);
MAX7219Send(0x01, bcd);
while(1);
} |
When this code runs, it overlaps on previously written digits. i.e. not clear the previous digits.
You have an electrical fault and the digits that should be on are off and vice versa
LED DISPLAY (all LED Digits) randomly on/off (like glitching). It is not staying on or off for a long time. What could be the reason. Now I have bought separate LED digits and combined myself to make LED DISPLAY. Earlier I have bought readymade LED Digit Panel (small 8 digits) from ebay. But that modules also showed same behaviour of glitching. But when we run the code, it displayed the result correct (SPI module used, NOT bitbanging).
This means one of the digits is probably slightly different to the others but they are all similar
One of 6 Digit is different from other 5 LED Digits. First I bought 1 LED for testing. After this, I bought 5 LED digits. Both are different make. I hope so. But all are common anode. One of the 6 digits luminosity intensity is different (dull) from other 5 digits.
You have a software fault and the address bits in the SPI word are incorrect.
The code is given above FYR. Pl check.
Code C - [expand] |
1
| My guess is the electrical scenario, remember the outputs of the MAX7219 are expected to sink current or source current so you may need to add resistors appropriately to allow some current to flow instead of just assuming voltages are turning on or off. |
I have used 300R to give 40mA to each Digit. Is that not enough?
any suggestions?
thanks in advance.
- - - Updated - - -
+12V -> 300R -> PNP -> LED DIGIT VDD PIN when MAX7219 sink the DIG pin.
Picture attached FYR.
- - - Updated - - -
10K RESISTOR USED AS Rset of MAX7219.