@@ -11,21 +11,25 @@
#include "mode.h"
#include "zoom.h"
static uint16_t dac = 32768 ;
static uint16_t dac = DAC_MID ;
void sweep(void)
{
int32_t d;
int16_t a;
#define SWEEP ((DAC_HIGH - DAC_LOW) * (int32_t)2000 / 65535)
/* sweep range */
for (d = (int32_t)dac - 2000; d < (int32_t)dac + 2000; d++) {
if (d < 0x0000) {
uart1_put_string("0 0\r\n");
for (d = (int32_t)dac - SWEEP; d < (int32_t)dac + SWEEP; d++) {
if (d < DAC_LOW) {
uart1_put_dec(DAC_LOW);
uart1_put_string(" 0\r\n");
continue;
}
if (d > 0xffff) {
uart1_put_string("65535 0\r\n");
if (d > DAC_HIGH) {
uart1_put_dec(DAC_HIGH);
uart1_put_string(" 0\r\n");
continue;
}
dac_write(d);
@@ -50,6 +54,7 @@ void run_debug(void)
uart1_put_string("Zoom NILM Debug\r\n");
while (1) {
dac = dac & DAC_HIGH; // mask off invalid bits
dac_write(dac);
uart1_put_hex16(dac);
uart1_put(' ');
@@ -92,7 +97,7 @@ void run_debug(void)
// set DAC to midpoint
case '0':
dac = 32768 ;
dac = DAC_MID ;
break;
// set DAC to specified hex value