jayanth.devarayanadurga
Banned
- 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
Why this design not working. I have attached mikroC PRO PIC file and Proteus file. I see data is being transmitted by SPI Data is valid in SPI debugger) but display are not lighting up. Actually none of the MAX6954's output is working. It is grayed out.
Edit: My new mikroC PRO PIC Code
Edit: My new mikroC PRO PIC Code
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 104 105 106 107 108 109 110 111 112 113 114 115 116 #define reg_noOp 0x00 #define reg_decodeMode 0x01 #define reg_globalIntensity 0x02 #define reg_scanLimit 0x03 #define reg_configuration 0x04 #define reg_displayTest 0x07 #define reg_digitType 0x0C #define reg_intensity10 0x10 #define reg_intensity32 0x11 #define reg_intensity54 0x12 #define reg_intensity76 0x13 #define reg_intensity10a 0x14 #define reg_intensity32a 0x15 #define reg_intensity54a 0x16 #define reg_intensity76a 0x17 #define USE_GLOBAL 0x00 #define USE_DISCRETE 0x40 #define RUN 0x01 #define SHUTDOWN 0x00 #define reg_digit0 0x60 #define reg_digit1 0x61 #define reg_digit2 0x62 #define reg_digit3 0x63 #define reg_digit4 0x64 #define reg_digit5 0x65 #define reg_digit6 0x66 #define reg_digit7 0x67 #define reg_digit0a 0x68 #define reg_digit1a 0x69 #define reg_digit2a 0x6A #define reg_digit3a 0x6B #define reg_digit4a 0x6C #define reg_digit5a 0x6D #define reg_digit6a 0x6E #define reg_digit7a 0x6F sbit Chip_Select at RC6_bit; sbit Chip_Select_Direction at TRISC6_bit; sbit CLK at RC3_bit; sbit CLK_Direction at TRISC3_bit; unsigned digits[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x53, 0x36, 0x37, 0x38, 0x39}; unsigned char digitsdp[] = {0xB0, 0XB1, 0XB2, 0XB3, 0XB4, 0X75, 0XB6, 0XB7, 0XB8, 0XB9}; unsigned char alphabets1[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0X4B, 0X4C, 0X4D, 0X4E, 0X4F, 0X50, 0X51, 0X52, 0X53, 0X54, 0X55, 0X56, 0X57, 0X58, 0X59, 0X5A}; unsigned char alphabets2[] = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0X6B, 0X6C, 0X6D, 0X6E, 0X6F, 0X70, 0X71, 0X72, 0X73, 0X74, 0X75, 0X76, 0X77, 0X78, 0X79, 0X7A}; void MAX6954_Write(unsigned char command, unsigned char data_); void MAX6955_Init(); void MAX6954_Write(unsigned char command, unsigned char data_) { //CLK = 0; Chip_Select = 0; SPI1_Write(command); SPI1_Write(data_); Chip_Select = 1; //CLK = 0; } void MAX6955_Init() { MAX6954_Write(reg_decodeMode, 0x00); MAX6954_Write(reg_scanLimit, 0x07); MAX6954_Write(reg_configuration, (RUN|USE_DISCRETE)); MAX6954_Write(reg_globalIntensity, 0x13); MAX6954_Write(reg_digitType, 0x00); MAX6954_Write(reg_displayTest, 0x01); delay_ms(500); MAX6954_Write(reg_displayTest, 0x00); } unsigned char i = 0, j = 0, strvolt[23], dpset = 0; float volt = 0.0; void main(){ TRISB = 0x00; TRISC = 0x00; TRISC.F4 = 1; CMCON = 0X07; ADCON0 = 0b10000000; ADCON1 = 0b11001110; CVRCON.CVROE = 0; Chip_Select = 1; SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH); MAX6955_Init(); while(1){ volt = ADC_Read(0); volt = volt * (5.0 / 1023.0) * 60.0; FloatToStr(volt, strvolt); j = 0; for(i = 0; i < 8; i++){ if(strvolt[i] != '.'){ if(dpset == 0) MAX6954_Write(0x20 + i, digits[strvolt[i] - 0x30]); else if(dpset == 1) MAX6954_Write(0x20 + i - 1, digits[strvolt[i] - 0x30]); } else if(strvolt[i] == '.'){ MAX6954_Write(0x20 + (i - 1), digitsdp[strvolt[i - 1] - 0x30]); dpset = 1; } } dpset = 0; MAX6954_Write(0x27, alphabets2[21]); Delay_ms(1000); } }
Attachments
Last edited: