Skip to content
Snippets Groups Projects
Commit 798434db authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Removed old comments from experiment.c. Changed CA CC interrupt priority to MED.

parent 38ae6412
No related merge requests found
......@@ -268,8 +268,6 @@ void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_
printf("D\n\r"); //signal end of experiment
// printf("Time: %lu s \n\r", rtc_get_time());
return;
}
......@@ -293,7 +291,6 @@ void lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first_ru
uint16_t dacindex_start = ceil(start*(65536/(double)3000)+32768);
dacindex_stop = ceil(stop*(65536/(double)3000)+32768);
// uint16_t period;
uint32_t timer_period;
uint16_t temp_div;
......@@ -402,9 +399,8 @@ static void porte_int0_lsv(void){
static uint16_t last_value = 0;
uint32_t current = TCC1.CNT;
printf("B\n");
send_data_uint16((current+last_value)>>1);
send_data_int32(result);
// 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
send_data_uint16((current+last_value)>>1); //DAC value is average of current and last timer - approximation of center of averaging window
send_data_int32(result);
last_value = (uint16_t)current;
printf("\n");
......@@ -459,7 +455,7 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[])
tc_write_clock_source(&TCC0, TC_CLKSEL_EVCH0_gc);
tc_set_direction(&TCC0, TC_UP);
tc_enable_cc_channels(&TCC0, TC_CCAEN);
tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_HI);
tc_set_cca_interrupt_level(&TCC0, TC_INT_LVL_MED);
TCC0.CNT = 0;
pot_exp_start();
......@@ -471,7 +467,6 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[])
RTC.CNT=0;
max5443_set_voltage1(step_dac[i]);
printf("#DAC: %u\n\r", step_dac[i]);
//PORTE.INTCTRL = PORT_INT0LVL_LO_gc;
PORTD.INTCTRL = PORT_INT0LVL_LO_gc;
while (up !=0);
}
......@@ -492,7 +487,6 @@ static void portd_int0_ca(void){
send_data_uint16(RTC.CNT);
send_data_int32(data);
printf("\n");
// printf("%u.%.3u %ld\n\r", TCC0.CNT, RTC.CNT, ads1255_read_fast24());
}
static void ca_cca_callback(void){
......@@ -500,7 +494,6 @@ 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;
return;
......@@ -516,16 +509,9 @@ void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_h
* @param pulse_height Pulse amplitude in mV.
* @param frequency Frequency in Hz.
*/
//check experiment limits
// if((start-pulse_height)<-1500 || (start+pulse_height)>(1500)|| start == stop || stop<-1500 || (stop+pulse_height)>1500 || step<1 || step>1500 || pulse_height > 1500 || pulse_height < 1)
// {
// printf("ERR: Experiment parameters outside limits\n\r");
// //return;
// }
int32_t forward = 0;
int32_t reverse = 0;
// int32_t data_buffer;
uint8_t direction;
uint16_t dacindex_start = ceil((start)*(65536/(double)3000))+32768;
uint16_t dacindex_stop = ceil(stop*(65536/(double)3000))+32768;
......@@ -533,9 +519,6 @@ void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_h
uint16_t dacindex_pulse_height = ceil(pulse_height*(65536/(double)3000));
uint16_t dacindex = dacindex_start;
uint32_t period;
// int16_t fgain = -1;
// int16_t rgain = -1;
if (start < stop)
direction = 1;
......@@ -595,16 +578,13 @@ void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_h
pot_exp_start();
TCF0.CNT = 0;
while (!tc_is_overflow(&TCF0));
ads1255_wakeup();
ads1255_wakeup(); //synchronize ADC
TCF0.CNT = 0;
while ((dacindex <= dacindex_stop && direction == 1) || (dacindex >= dacindex_stop && direction == 0)){
tc_clear_overflow(&TCF0);
printf("%u %ld %ld\n\r", dacindex, forward, reverse); //data output
// forward = 0;
// reverse = 0;
while (!tc_is_overflow(&TCF0)){ //convert continuously until tc overflow - datum is last collected point
while (ioport_pin_is_low(IOPORT_CREATE_PIN(PORTD, 5))); //wait for next valid datum
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment