diff --git a/DSTAT-temp/src/experiment.c b/DSTAT-temp/src/experiment.c index 925092feae18db0de3b4cf19d0425c90cd746a45..f83f225af6133f81b425bc47dd64492be426d375 100644 --- a/DSTAT-temp/src/experiment.c +++ b/DSTAT-temp/src/experiment.c @@ -220,11 +220,11 @@ void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_ return; } - RTC.CTRL = RTC_PRESCALER_OFF_gc; - while (RTC.STATUS & RTC_SYNCBUSY_bm); - RTC.CNT = 0; - RTC.PER = 0xffff; - RTC.CTRL = RTC_PRESCALER_DIV1024_gc; // 1 s tick +// RTC.CTRL = RTC_PRESCALER_OFF_gc; +// while (RTC.STATUS & RTC_SYNCBUSY_bm); +// RTC.CNT = 0; +// RTC.PER = 0xffff; +// RTC.CTRL = RTC_PRESCALER_DIV1024_gc; // 1 s tick while(scans > 0){ if (start != v1){ @@ -242,7 +242,7 @@ void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_ firstrun = 0; } - printf("Time: %lu s \n\r", rtc_get_time()); +// printf("Time: %lu s \n\r", rtc_get_time()); return; } @@ -371,37 +371,45 @@ static void porte_int0_lsv(void){ /** * ISR for taking LSV measurements. */ - int32_t result; - - if (autogain_enable == 0){ -// while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); - result=ads1255_read_fast24(); - goto noauto; - } - - else{ - while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); - result=ads1255_read(); - } + int32_t result; +// +// if (autogain_enable == 0){ +// // while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); +// result=ads1255_read_fast24(); +// goto noauto; +// } +// +// else{ +// while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); +// result=ads1255_read(); +// } +// +// if (autogainswitch()==0){ +// noauto: +// // if (g_gain == POT_GAIN_300) +// // printf("%u %ld\n\r", TCC1.CNT,result); +// // else if (g_gain == POT_GAIN_3k) +// // printf("%u %ld\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_30k) +// // printf("%u %ld000\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_300k) +// // printf("%u %ld00\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_3M) +// // printf("%u %ld0\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_30M) +// // printf("%u %ld\n\r", TCC1.CNT, result); +// // else +// printf("%u %ld\n\r", TCC1.CNT, result); +// } +// +// return; + static uint16_t last_value = 0; + uint32_t current = TCC1.CNT; + + result = ads1255_read_fast24(); + printf("%lu %ld\n\r", (current+last_value)>>1, result); //DAC value is average of current and last timer - approximation of center of averaging window + last_value = (uint16_t)current; - if (autogainswitch()==0){ - noauto: - if (g_gain == POT_GAIN_300) - printf("%u %ld00000\n\r", TCC1.CNT,result); - else if (g_gain == POT_GAIN_3k) - printf("%u %ld0000\n\r", TCC1.CNT, result); - else if (g_gain == POT_GAIN_30k) - printf("%u %ld000\n\r", TCC1.CNT, result); - else if (g_gain == POT_GAIN_300k) - printf("%u %ld00\n\r", TCC1.CNT, result); - else if (g_gain == POT_GAIN_3M) - printf("%u %ld0\n\r", TCC1.CNT, result); - else if (g_gain == POT_GAIN_30M) - printf("%u %ld\n\r", TCC1.CNT, result); - else - printf("%u %ld\n\r", TCC1.CNT, result); - } - return; } diff --git a/DSTAT1.atsuo b/DSTAT1.atsuo index 4df45696c86b841780d118e13d81732a79ca7946..082d5d758ee5b59ea58f31c58f6a5f3a30c0f42d 100644 Binary files a/DSTAT1.atsuo and b/DSTAT1.atsuo differ