|
|
@@ -55,8 +55,14 @@ void TISR_HANDLER(5) |
|
|
|
/* Convert ADC value to current */ |
|
|
|
i = adc12_to_current(v); |
|
|
|
|
|
|
|
#if 0 |
|
|
|
/* Adjust DAC to null this current to 0 */ |
|
|
|
dac_current -= i; |
|
|
|
#else |
|
|
|
/* If this current exceeds +-1A, cancel it out at the DAC */ |
|
|
|
if (i < -1.0 || i > 1.0) |
|
|
|
dac_current -= i; |
|
|
|
#endif |
|
|
|
|
|
|
|
if (dac_current < dac_current_min) |
|
|
|
dac_current = dac_current_min; |
|
|
@@ -85,12 +91,15 @@ void send_to_pc(uint16_t adc, uint16_t dac) |
|
|
|
|
|
|
|
void degauss(void) |
|
|
|
{ |
|
|
|
return; |
|
|
|
#if 0 |
|
|
|
dac_write(65535); /* max */ |
|
|
|
msleep(25); |
|
|
|
dac_write(0); /* min */ |
|
|
|
msleep(25); |
|
|
|
dac_write(32768); /* middle */ |
|
|
|
msleep(25); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void run_debug(void) |
|
|
@@ -214,6 +223,8 @@ int main(void) |
|
|
|
led_init(); |
|
|
|
|
|
|
|
led_on(); |
|
|
|
/* debug */ |
|
|
|
TRISAbits.TRISA9 = 0; |
|
|
|
/* Detect jumper on B10/B11 */ |
|
|
|
//TRISCbits.TRISC13 = 1; |
|
|
|
//CNPU1bits.CN1PUE = 1; |
|
|
@@ -232,9 +243,9 @@ int main(void) |
|
|
|
/* If PGD is externally tied to ground, use MODE_1 |
|
|
|
(Short ICD pins 3 and 4) */ |
|
|
|
// if (PORTCbits.RC13 == 0) |
|
|
|
MODE_1(); |
|
|
|
// MODE_1(); |
|
|
|
// else |
|
|
|
// MODE_2(); |
|
|
|
MODE_2(); |
|
|
|
|
|
|
|
for (;;) |
|
|
|
continue; |
|
|
|