aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/TemperatureDataLogger/TempDataLogger.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-30 13:35:24 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-30 13:35:24 +0000
commit0ea819f7814a9eda0d5bfbb5125abb113634724f (patch)
tree27e471012214b72c15822cfe72d5ad6444656d38 /Projects/TemperatureDataLogger/TempDataLogger.c
parent7beafc64e2944b3e0bd41f7621bf7dc93855f859 (diff)
downloadlufa-0ea819f7814a9eda0d5bfbb5125abb113634724f.tar.gz
lufa-0ea819f7814a9eda0d5bfbb5125abb113634724f.tar.bz2
lufa-0ea819f7814a9eda0d5bfbb5125abb113634724f.zip
Fix TemperatureDataLogger - sample tick timer wasn't being initialized in the correct CTC mode.
Diffstat (limited to 'Projects/TemperatureDataLogger/TempDataLogger.c')
-rw-r--r--Projects/TemperatureDataLogger/TempDataLogger.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Projects/TemperatureDataLogger/TempDataLogger.c b/Projects/TemperatureDataLogger/TempDataLogger.c
index 6cb1792a4..5872a0830 100644
--- a/Projects/TemperatureDataLogger/TempDataLogger.c
+++ b/Projects/TemperatureDataLogger/TempDataLogger.c
@@ -64,7 +64,7 @@ FATFS DiskFATState;
/** FAT Fs structure to hold a FAT file handle for the log data write destination. */
FIL TempLogFile;
-/** Counter to count the number of 10 millisecond tick that has elapsed since the last sample */
+/** Counter to count the number of 10 millisecond ticks that has elapsed since the last sample */
uint16_t CurrentLogTick;
@@ -73,6 +73,10 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
if (CurrentLogTick++ != LOG_INTERVAL_10MS)
return;
+ uint8_t LEDMask = LEDs_GetLEDs();
+
+ LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
+
CurrentLogTick = 0;
if (USB_DeviceState == DEVICE_STATE_Unattached)
@@ -80,6 +84,8 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
f_printf(&TempLogFile, "%d Degrees\r\n", Temperature_GetTemperature());
f_sync(&TempLogFile);
}
+
+ LEDs_SetAllLEDs(LEDMask);
}
@@ -96,11 +102,12 @@ int main(void)
f_mount(0, &DiskFATState);
f_open(&TempLogFile, LOG_FILENAME, FA_OPEN_ALWAYS | FA_WRITE);
f_lseek(&TempLogFile, TempLogFile.fsize);
-
- /* Write out the log seperator line */
f_printf(&TempLogFile, "===========================\r\n");
- Temperature_GetTemperature(); // Discard first temperature reading to ensure accuracy
-
+
+ /* Discard the first sample from the temperature sensor, as it is generally incorrect */
+ uint8_t Dummy = Temperature_GetTemperature();
+ (void)Dummy;
+
for (;;)
{
MS_Device_USBTask(&Disk_MS_Interface);
@@ -128,8 +135,7 @@ void SetupHardware(void)
/* 10ms interval timer configuration */
OCR1A = (((F_CPU / 1024) / 100) - 1);
- TCCR1A = (1 << WGM01); // CTC mode
- TCCR1B = (1 << CS12) | (1 << CS10); // Fcpu/1024 speed
+ TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10); // CTC mode, Fcpu/1024 speed
TIMSK1 = (1 << OCIE1A);
/* Clear Dataflash sector protections, if enabled */
@@ -154,6 +160,7 @@ void EVENT_USB_Device_Disconnect(void)
f_mount(0, &DiskFATState);
f_open(&TempLogFile, LOG_FILENAME, FA_OPEN_ALWAYS | FA_WRITE);
f_lseek(&TempLogFile, TempLogFile.fsize);
+ f_printf(&TempLogFile, "===========================\r\n");
}
/** Event handler for the library USB Configuration Changed event. */