blob: d456b494e91d30b4b49e8ec4e2c67964131be1b5 (
plain) (
blame)
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
|
#include "xc.h"
#include "display.h"
//Functions used for Display
void init7seg(void) {
CLKDIVbits.RCDIV = 0; //Set RCDIV=1:1 (default 2:1) 32MHz or FCY/2=16M
AD1PCFG = 0x9fff; //sets all pins to digital I/O
TRISA = 0b0000000000011111; //set port A to inputs,
TRISB = 0b0000000000000011; //and port B to outputs
LATA = 0x0000; //Set all of port A to LOW
LATB = 0x0000; //and all of port B to LOW
}
void showChar7seg(char myChar, enum DIGIT myDigit) {
LATB &= 0x00;
switch (myChar) {
case '0':
LATB ^= (0b11 << 2);
break;
case '1':
LATB ^= (0b10011111 << 2);
break;
case '2':
LATB ^= (0b00100101 << 2);
break;
case '3':
LATB ^= (0b1101 << 2);
break;
case '4':
LATB ^= (0b10011001 << 2);
break;
case '5':
LATB ^= (0b1001001 << 2);
break;
case '6':
LATB ^= (0b1000001 << 2);
break;
case '7':
LATB ^= (0b11111 << 2);
break;
case '8':
LATB ^= (0b1 << 2);
break;
case '9':
LATB ^= (0b1001 << 2);
break;
case 'A':
LATB ^= (0b10001 << 2);
break;
case 'b':
LATB ^= (0b11000001 << 2);
break;
case 'C':
LATB ^= (0b01100011 << 2);
break;
case 'd':
LATB ^= (0b10000101 << 2);
break;
case 'E':
LATB ^= (0b01100001 << 2);
break;
case 'F':
LATB ^= (0b01110001 << 2);
break;
default:
LATB ^= (0b11111111 << 2);
break;
} //END OF SWITCH
LATB |= myDigit;
}
|