milan.rajik
Banned
In this code assign the correct 6 bit and 8 bit MSB and LSB values to vale12send and vale22send variables.
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 sbit SH_CP at RD0_bit; sbit SH_CP_Direction at TRISD0_bit; sbit ST_CP at RD2_bit; sbit ST_CP_Direction at TRISD2_bit; sbit DS at RD1_bit; sbit DS_Direction at TRISD1_bit; char uart_rd; unsigned char value12hc595 = 0, value22hc595 = 0; void interrupt() { if(RCIF_bit) { if(OERR_bit) { CREN_bit = 0; CREN_bit = 1; OERR_bit = 0; } uart_rd = UART1_Read(); RCIF_bit = 0; } } void SPI_Send(unsigned char s1, unsigned char s2) { unsigned long mask; char i = 0; mask = 0x20; for(i = 0; i < 6; i++, mask >>= 1) { if(s1 & mask) DS = 1; else DS = 0; SH_CP = 1; Delay_ms(5); SH_CP = 0; } for(i = 0; i < 36; i++) { DS = 1; SH_CP = 1; Delay_ms(5); SH_CP = 0; } mask = 0x80; for(i = 0; i < 8; i++, mask >>= 1) { if(s2 & mask) DS = 1; else DS = 0; SH_CP = 1; Delay_ms(5); SH_CP = 0; } ST_CP = 1; Delay_ms(5); ST_CP = 0; } void main() { CMCON = 0x07; ADCON1 = 0x87; TRISA = 0xC0; TRISB = 0x00; TRISC = 0x80; TRISD = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; SH_CP_Direction = 0; SH_CP = 0; ST_CP_Direction = 0; ST_CP = 0; DS_Direction = 0; DS = 0; UART1_Init(9615); Delay_ms(200); RCIF_bit = 0; RCIE_bit = 1; PEIE_bit = 1; GIE_bit = 1; while(1) { if(uart_rd) { switch(uart_rd) { case 'a': value12hc595 = 0b100000; value22hc595 = 0b10000000; break; case 'b': value12hc595 = 0b101000; value22hc595 = 0b01000000; break; case 'c': value12hc595 = 0b110000; value22hc595 = 0b00100000; break; case 'd': value12hc595 = 0b110100; value22hc595 = 0b00010000; break; case 'e': value12hc595 = 0b100100; value22hc595 = 0b00001000; break; case 'f': value12hc595 = 0b111000; value22hc595 = 0b00000100; break; case 'g': value12hc595 = 0b111100; value22hc595 = 0b00000010; break; case 'h': value12hc595 = 0b101100; value22hc595 = 0b00000001; break; case 'i': value12hc595 = 0b011000; value22hc595 = 0b11000000; break; case 'j': value12hc595 = 0b011000; value22hc595 = 0b01100000; break; case 'k': value12hc595 = 0b100010; value22hc595 = 0b00110000; break; case 'l': value12hc595 = 0b101010; value22hc595 = 0b00011000; break; case 'm': value12hc595 = 0b110010; value22hc595 = 0b00001100; break; case 'n': value12hc595 = 0b110110; value22hc595 = 0b00000110; break; case 'o': value12hc595 = 0b100110; value22hc595 = 0b00000011; break; case 'p': value12hc595 = 0b111010; value22hc595 = 0b10000001; break; case 'q': value12hc595 = 0b111110; value22hc595 = 0b11100000; break; case 'r': value12hc595 = 0b101110; value22hc595 = 0b01110000; break; case 's': value12hc595 = 0b011010; value22hc595 = 0b00111000; break; case 't': value12hc595 = 0b011110; value22hc595 = 0b00011100; break; case 'u': value12hc595 = 0b100011; value22hc595 = 0b00001110; break; case 'v': value12hc595 = 0b101011; value22hc595 = 0b00000111; break; case 'w': value12hc595 = 0b011101; value22hc595 = 0b10000011; break; case 'x': value12hc595 = 0b110011; value22hc595 = 0b11000001; break; case 'y': value12hc595 = 0b110111; value22hc595 = 0b11110000; break; case 'z': value12hc595 = 0b101110; value22hc595 = 0b01111000; break; case '0': value12hc595 = 0b011100; value22hc595 = 0b00111100; break; case '1': value12hc595 = 0b100000; value22hc595 = 0b00011110; break; case '2': value12hc595 = 0b101000; value22hc595 = 0b00001111; break; case '3': value12hc595 = 0b110000; value22hc595 = 0b10000111; break; case '4': value12hc595 = 0b110100; value22hc595 = 0b11000011; break; case '5': value12hc595 = 0b100100; value22hc595 = 0b11100001; break; } SPI_Send(value12hc595, value22hc595); uart_rd = 0; } } }