Browse Source

misc changes

Thomas Buck 12 years ago
parent
commit
6d7dd21fe4
3 changed files with 19 additions and 6 deletions
  1. 15
    3
      CubeFirmware/cube.c
  2. 1
    1
      CubeFirmware/main.c
  3. 3
    2
      CubeFirmware/strings.c

+ 15
- 3
CubeFirmware/cube.c View File

28
 
28
 
29
 #ifdef DEBUG
29
 #ifdef DEBUG
30
 #include "serial.h"
30
 #include "serial.h"
31
+#include "strings.h"
31
 #endif
32
 #endif
32
 #include "cube.h"
33
 #include "cube.h"
33
 
34
 
63
 inline void isrCall(void);
64
 inline void isrCall(void);
64
 
65
 
65
 volatile uint32_t timesTriggered = 0;
66
 volatile uint32_t timesTriggered = 0;
67
+volatile uint8_t warningDisplayed = 0;
66
 
68
 
67
 uint32_t getTriggerCount(void) {
69
 uint32_t getTriggerCount(void) {
68
 	return timesTriggered;
70
 	return timesTriggered;
99
 }
101
 }
100
 
102
 
101
 void initCube(void) {
103
 void initCube(void) {
102
-	TCCR1A |= (1 << WGM12); // CTC Mode
103
-	TCCR1B |= (1 << CS10); // Prescaler: 1
104
+	TCCR1B |= (1 << CS10) | (1 << WGM12); // Prescaler: 1, CTC Mode
104
 	OCR1A = COUNT;
105
 	OCR1A = COUNT;
105
 	TIMSK = (1 << OCIE1A); // Enable Output Compare Interrupt
106
 	TIMSK = (1 << OCIE1A); // Enable Output Compare Interrupt
106
 }
107
 }
112
 ISR(TIMER1_COMPA_vect) {
113
 ISR(TIMER1_COMPA_vect) {
113
 	isrCall();
114
 	isrCall();
114
 	timesTriggered++;
115
 	timesTriggered++;
116
+#ifdef DEBUG
117
+	if (TIFR & TOV1) {
118
+		if (warningDisplayed) {
119
+			serialWrite('!');
120
+		} else {
121
+			serialWriteString(getString(27));
122
+			warningDisplayed++;
123
+		}
124
+		TIFR |= (1 << TOV1); // Clear flag
125
+	}
126
+#endif
115
 }
127
 }
116
 
128
 
117
 // Data is sent to 8 Fet bits...
129
 // Data is sent to 8 Fet bits...
142
 		layer = 0;
154
 		layer = 0;
143
 		changedFlag = 0;
155
 		changedFlag = 0;
144
 	}
156
 	}
145
-	// setFet(0);
157
+	setFet(0);
146
 	for (; latchCtr < 8; latchCtr++) {
158
 	for (; latchCtr < 8; latchCtr++) {
147
 		setLatch(latchCtr, imgBuffer[layer][latchCtr]); // Put out all the data
159
 		setLatch(latchCtr, imgBuffer[layer][latchCtr]); // Put out all the data
148
 	}
160
 	}

+ 1
- 1
CubeFirmware/main.c View File

189
 			serialHandler((char)(serialGet()));
189
 			serialHandler((char)(serialGet()));
190
 		}
190
 		}
191
 
191
 
192
-		if ((getSystemTime() >= 10000) && ((DebugDone & 1) == 0)) {
192
+		if ((getSystemTime() >= 1000) && ((DebugDone & 1) == 0)) {
193
 			printTime();
193
 			printTime();
194
 			serialWriteString(ltoa(getTriggerCount(), buffer, 10));
194
 			serialWriteString(ltoa(getTriggerCount(), buffer, 10));
195
 			serialWrite('\n');
195
 			serialWrite('\n');

+ 3
- 2
CubeFirmware/strings.c View File

56
 char stringNoMoreHeap[] PROGMEM = "Ran out of Heap... Bye\n"; // 24
56
 char stringNoMoreHeap[] PROGMEM = "Ran out of Heap... Bye\n"; // 24
57
 char stringKilledAnimation[] PROGMEM = "Animation aborted!\n"; // 25
57
 char stringKilledAnimation[] PROGMEM = "Animation aborted!\n"; // 25
58
 char stringHelp9[] PROGMEM = "(i)nterrupt count\n"; // 26
58
 char stringHelp9[] PROGMEM = "(i)nterrupt count\n"; // 26
59
+char stringTimerOverflow[] PROGMEM = "Cube Timer Overflowed (now !)\n"; // 27
59
 
60
 
60
 // Last index + 1
61
 // Last index + 1
61
-#define STRINGNUM 27
62
+#define STRINGNUM 28
62
 
63
 
63
 PGM_P stringTable[STRINGNUM] PROGMEM = { stringVersion, stringSelfTestError, stringInit,
64
 PGM_P stringTable[STRINGNUM] PROGMEM = { stringVersion, stringSelfTestError, stringInit,
64
 								stringAudioError, stringMemError, stringMemWriteError,
65
 								stringAudioError, stringMemError, stringMemWriteError,
67
 								stringByte, stringWritten, stringCount, stringSelfTest,
68
 								stringByte, stringWritten, stringCount, stringSelfTest,
68
 								stringKillCount, stringAccessError, stringAudioData,
69
 								stringKillCount, stringAccessError, stringAudioData,
69
 								stringSnakeControl, stringNoMoreHeap, stringKilledAnimation,
70
 								stringSnakeControl, stringNoMoreHeap, stringKilledAnimation,
70
-								stringHelp9 };
71
+								stringHelp9, stringTimerOverflow };
71
 
72
 
72
 char stringNotFoundError[] PROGMEM = "String not found!\n";
73
 char stringNotFoundError[] PROGMEM = "String not found!\n";
73
 
74
 

Loading…
Cancel
Save