|
|
@@ -10,7 +10,6 @@ |
|
|
|
#include "util.h" |
|
|
|
#include "mode.h" |
|
|
|
#include "led.h" |
|
|
|
#include "zoom.h" |
|
|
|
#include "packet.h" |
|
|
|
|
|
|
|
int send_data = 0; |
|
|
@@ -41,7 +40,7 @@ void TISR_HANDLER(5) |
|
|
|
LATAbits.LATA9 = 1; |
|
|
|
#endif |
|
|
|
timer_clear_txif(5); |
|
|
|
|
|
|
|
|
|
|
|
/* Get most recent sample from 12-bit ADC. */ |
|
|
|
v = adc_get(); |
|
|
|
|
|
|
@@ -51,20 +50,22 @@ void TISR_HANDLER(5) |
|
|
|
/* Send data to PC */ |
|
|
|
if (++count >= (TIMER_RATE / PC_RATE)) { |
|
|
|
count = 0; |
|
|
|
|
|
|
|
|
|
|
|
/* Send most recent sample and old DAC value */ |
|
|
|
send_adc = v; |
|
|
|
send_dac = dac_cmd; |
|
|
|
send_data = 1; |
|
|
|
} |
|
|
|
|
|
|
|
#define WINDOW |
|
|
|
#define WINDOW |
|
|
|
#ifdef WINDOW |
|
|
|
/* If ADC value is outside the window, step DAC */ |
|
|
|
if (v < ADC_WINDOW_MIN) |
|
|
|
dac_cmd = adc_to_dac(dac_cmd, v, ADC_WINDOW_MIN_STEPTO, g_scale); |
|
|
|
dac_cmd = adc_to_dac(dac_cmd, v, ADC_WINDOW_MIN_STEPTO, |
|
|
|
g_scale); |
|
|
|
else if (v > ADC_WINDOW_MAX) |
|
|
|
dac_cmd = adc_to_dac(dac_cmd, v, ADC_WINDOW_MAX_STEPTO, g_scale); |
|
|
|
dac_cmd = adc_to_dac(dac_cmd, v, ADC_WINDOW_MAX_STEPTO, |
|
|
|
g_scale); |
|
|
|
#else |
|
|
|
dac_cmd = adc_to_dac(dac_cmd, v, 1024, g_scale); |
|
|
|
#endif |
|
|
@@ -113,7 +114,9 @@ void run_normal(void) |
|
|
|
uint16_t a, d, o; |
|
|
|
disable_int({ |
|
|
|
if (possibly_clamped) { |
|
|
|
/* Mark a possible overflow in the output */ |
|
|
|
/* Mark a possible |
|
|
|
* overflow in the |
|
|
|
* output */ |
|
|
|
o = 1; |
|
|
|
possibly_clamped = 0; |
|
|
|
} else o = 0; |
|
|
|