diff --git a/DSTAT-temp/src/config/conf_clock.h b/DSTAT-temp/src/config/conf_clock.h index 18439059e469a62571b79ae0d2c5cf7ea6d38fe7..7a734eb7dc86b8b3c996c2f527cac91607b8aae4 100644 --- a/DSTAT-temp/src/config/conf_clock.h +++ b/DSTAT-temp/src/config/conf_clock.h @@ -93,6 +93,6 @@ #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF /* Use to enable and select RTC clock source */ -//#define CONFIG_RTC_SOURCE SYSCLK_RTCSRC_ULP +#define CONFIG_RTC_SOURCE SYSCLK_RTCSRC_ULP #endif /* CONF_CLOCK_H_INCLUDED */ diff --git a/DSTAT-temp/src/config/conf_rtc.h b/DSTAT-temp/src/config/conf_rtc.h index 22efd923f4c1fac6003e9c20e90510e4ebf3f57e..2ba63d99d80a7d84a9e0bfcef32ef26117236c81 100644 --- a/DSTAT-temp/src/config/conf_rtc.h +++ b/DSTAT-temp/src/config/conf_rtc.h @@ -43,8 +43,8 @@ #ifndef CONF_RTC_H #define CONF_RTC_H -#define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1024_gc +#define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV1_gc #define CONFIG_RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_LO_gc #define CONFIG_RTC_OVERFLOW_INT_LEVEL RTC_OVFINTLVL_LO_gc -#endif /* CONF_RTC_H */ +#endif /* CONF_RTC_H */ \ No newline at end of file diff --git a/DSTAT-temp/src/experiment.c b/DSTAT-temp/src/experiment.c index f83f225af6133f81b425bc47dd64492be426d375..7e742439b6675d32b715d4b76e97058808f0baf6 100644 --- a/DSTAT-temp/src/experiment.c +++ b/DSTAT-temp/src/experiment.c @@ -444,11 +444,12 @@ void chronoamp(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]){ while (RTC.STATUS & RTC_SYNCBUSY_bm); RTC.PER = 999; while (RTC.STATUS & RTC_SYNCBUSY_bm); - RTC.CTRL = RTC_PRESCALER_DIV1_gc; + RTC.CTRL = RTC_PRESCALER_DIV1_gc; //1ms tick + RTC.CNT = 0; - EVSYS.CH0MUX = EVSYS_CHMUX_RTC_OVF_gc; + EVSYS.CH0MUX = EVSYS_CHMUX_RTC_OVF_gc; //EV CH0 -- RTC overflow 1s - portd_int0_callback = portd_int0_ca; + portd_int0_callback = portd_int0_ca; //ADC interrupt tc_enable(&TCC0); tc_set_cca_interrupt_callback(&TCC0, ca_cca_callback); @@ -486,32 +487,14 @@ void chronoamp(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]){ } static void portd_int0_ca(void){ - if (autogainswitch()==0){ - //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - if (g_gain == POT_GAIN_300) - printf("%u, %ld00000\n\r", TCC1.CNT, ads1255_read()); - else if (g_gain == POT_GAIN_3k) - printf("%u, %ld0000\n\r", TCC1.CNT, ads1255_read()); - else if (g_gain == POT_GAIN_30k) - printf("%u, %ld000\n\r", TCC1.CNT, ads1255_read()); - else if (g_gain == POT_GAIN_300k) - printf("%u, %ld00\n\r", TCC1.CNT, ads1255_read()); - else if (g_gain == POT_GAIN_3M) - printf("%u, %ld0\n\r", TCC1.CNT, ads1255_read()); - else if (g_gain == POT_GAIN_30M) - printf("%u, %ld\n\r", TCC1.CNT, ads1255_read()); - else - printf("%u, %lu\n\r", TCC1.CNT, ads1255_read()); - } - else{ - //while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTE, 3))); - while (ioport_pin_is_high(IOPORT_CREATE_PIN(PORTD, 5))); - ads1255_read(); - } + printf("%u.%.3u %ld\n\r", TCC0.CNT, RTC.CNT, ads1255_read_fast24()); } static void ca_cca_callback(void){ + /** + * Interrupt handler for CA. Triggers when counter matches CC to stop potential step. + * + */ //PORTE.INTCTRL = PORT_INT0LVL_OFF_gc; PORTD.INTCTRL = PORT_INT0LVL_OFF_gc; up = 0; diff --git a/DSTAT-temp/src/main.c b/DSTAT-temp/src/main.c index 5b84083c72e4b1c260cf97daaf668d9e1c298d75..906f954f184ee155f23fe7805083017fa5c85a68 100644 --- a/DSTAT-temp/src/main.c +++ b/DSTAT-temp/src/main.c @@ -140,7 +140,8 @@ int main(void){ g_gain = POT_GAIN_30k; pot_set_gain(); // max5443_set_voltage1(-1000*(65536/(double)3000)+32768); -// int16_t volt; + step_dac[0] = 32768/*(double)3.8*(65536/(double)3000)+32768*/; + step_seconds[0] = 10; while (1){ // scanf("%d",&volt); @@ -156,7 +157,38 @@ int main(void){ // } // delay_s(1); getchar(); - printf("#Start"); - cv_experiment(-1500,1499,-1500,1,100); + printf("no\n\r"); +/* cv_experiment(-1500,1499,-1500,1,100);*/ + g_gain = POT_GAIN_100; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_300; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_3k; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_30k; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_300k; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_3M; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_30M; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); + printf("no\n\r"); + g_gain = POT_GAIN_500M; + pot_set_gain(); + chronoamp(1,step_dac,step_seconds); } } \ No newline at end of file diff --git a/DSTAT-temp/src/max5443.c b/DSTAT-temp/src/max5443.c index 32acf53634ed2f9dc48d9c0dc38b135959f6e4bb..f5a9ee57fbac0403fe60bfa6871920c8f5e3fe8f 100644 --- a/DSTAT-temp/src/max5443.c +++ b/DSTAT-temp/src/max5443.c @@ -7,6 +7,8 @@ #include +volatile uint16_t max5443_offset = 105; + struct usart_spi_device spi_device_conf_c = { .id = IOPORT_CREATE_PIN(PORTC, 4) }; @@ -30,7 +32,7 @@ void max5443_set_voltage1(uint16_t dacindex){ // if (buffer.ui16 == dacindex) // return; - buffer.ui16 = dacindex; + buffer.ui16 = dacindex+max5443_offset; irqflags_t flags; flags = cpu_irq_save(); diff --git a/DSTAT-temp/src/max5443.h b/DSTAT-temp/src/max5443.h index af4bbc6f8851778c957a375fdd280bc68d6842f0..62dfae1fbb93d2cb95cb1e3223ed69d2c5a830f0 100644 --- a/DSTAT-temp/src/max5443.h +++ b/DSTAT-temp/src/max5443.h @@ -16,6 +16,7 @@ #include #include + void max5443_init_pins(void); void max5443_init_module(void); void max5443_set_voltage1(uint16_t dacindex); diff --git a/DSTAT1.atsuo b/DSTAT1.atsuo index 082d5d758ee5b59ea58f31c58f6a5f3a30c0f42d..8486ac1b10a7c166a918e4afc2d20a93653c87f2 100644 Binary files a/DSTAT1.atsuo and b/DSTAT1.atsuo differ