1 | C-Code
|
2 |
|
3 | ISR(INT2_vect) {
|
4 | DDRD = 0xFF; //Data out
|
5 | PORTC = VIA_CHIP_SEL + VIA_T2C_L * 4;
|
6 | VIA_WRITE();
|
7 | PORTD = 0x9;
|
8 | _delay_us(20); //settle down
|
9 |
|
10 | PORTC = VIA_CHIP_SEL + VIA_T2C_H * 4;
|
11 | VIA_WRITE();
|
12 | PORTD = 0x0;
|
13 | _delay_us(20); //settle down
|
14 | DDRD = 0x0; //Data in for next read cycle
|
15 | IRQflag6522 = 1; // <- kommt in Hauptprogramm nicht an. Zeitkritisch?
|
16 |
|
17 | }
|
18 |
|
19 | im Moment ruft main nur:
|
20 |
|
21 | while (1) {
|
22 | read6522Register2();
|
23 | }
|
24 |
|
25 |
|
26 | /************************************************************************
|
27 | *
|
28 | * read6522Register2: 6522 register dump
|
29 | * blank = xx bewirkt austasten (blinken) des zu editierenden Inhalts
|
30 | *
|
31 | ************************************************************************/
|
32 | void read6522Register2 (void) {
|
33 | unsigned int T2 = 0;
|
34 | static uint16_t irq6522 = 0;
|
35 |
|
36 | static int8_t count1 = 0; //blink 5x
|
37 | static int8_t count2 = 1; //15 items
|
38 | static unsigned long old = 0;
|
39 |
|
40 |
|
41 | //Timer ISR, calculate a nick of time
|
42 | if ((eternal - old) == 1) {
|
43 | count1++;
|
44 | }
|
45 | old = eternal;
|
46 |
|
47 | if (count1 == (2*5)) {
|
48 | count1 = 0;
|
49 | count2++;
|
50 | }
|
51 |
|
52 | if (blink == 1) {
|
53 | blank = count2;
|
54 | }
|
55 | else blank = 0;
|
56 | if (count2 > 15) count2 = 1;
|
57 |
|
58 |
|
59 | regStatus = read6522 (VIA_IOR_A);
|
60 | convDecToHex (255-regStatus);
|
61 | if (blank == 1 ) SendAscii(Touch160x104, 4* FONTWIDTH , 1*FONTHEIGHT," ");
|
62 | else SendAscii(Touch160x104, 4* FONTWIDTH , 1*FONTHEIGHT, buf2);
|
63 |
|
64 | .
|
65 | .
|
66 | .
|
67 |
|
68 | regStatus = read6522 (VIA_T2C_H);
|
69 | T2 = 65535 - (256 * regStatus + T2) ;
|
70 | convDecToHex (regStatus);
|
71 | if (blank == 14) SendAscii(Touch160x104, 8*FONTWIDTH , 7*FONTHEIGHT, " ");
|
72 | else SendAscii(Touch160x104, 8*FONTWIDTH , 7*FONTHEIGHT, buf2);
|
73 | regStatus = read6522 (VIA_T2C_L);
|
74 | T2 = regStatus;
|
75 | convDecToHex (regStatus);
|
76 | if (blank == 15) SendAscii(Touch160x104, 10*FONTWIDTH +3, 7*FONTHEIGHT , " ");
|
77 | else SendAscii(Touch160x104, 10*FONTWIDTH +3, 7*FONTHEIGHT , buf2);
|
78 |
|
79 |
|
80 | //check for interrupts ...funktioniert nicht
|
81 | if (IRQflag6522) {
|
82 | sprintf( buf1, "IRQs: %i", ++irq6522); //
|
83 | SendAscii(Touch160x104, 0, 8*FONTHEIGHT, buf1);
|
84 | IRQflag6522 = 0; //release
|
85 | }
|