diff --git a/csdr.c b/csdr.c
index 2951d8f..3a78c2b 100755
--- a/csdr.c
+++ b/csdr.c
@@ -2778,6 +2778,7 @@ int main(int argc, char *argv[])
sscanf(argv[4],"%f",&gain);
int decision_directed = !!(argc>5 && (!strcmp(argv[5], "--dd") || !strcmp(argv[5], "--decision_directed")));
+ if(decision_directed) fprintf(stderr, "csdr bpsk_costas_loop_cc: decision directed mode\n");
bpsk_costas_loop_state_t state;
init_bpsk_costas_loop_cc(&state, decision_directed, damping_factor, loop_bandwidth, gain);
diff --git a/grc_tests/test_bpsk_costas_loop.grc b/grc_tests/test_bpsk_costas_loop.grc
index 0abca69..b8d1183 100644
--- a/grc_tests/test_bpsk_costas_loop.grc
+++ b/grc_tests/test_bpsk_costas_loop.grc
@@ -140,7 +140,7 @@
value
- 0
+ 10
_enabled
@@ -180,7 +180,7 @@
num_steps
- 100
+ 1000
style
@@ -693,7 +693,7 @@
commandline
- csdr bpsk_costas_loop_cc $(csdr =2*pi/100) 0.707 1
+ csdr bpsk_costas_loop_cc $(csdr =2*pi/100) 0.707 300 --dd 2>/tmp/cout
comment
diff --git a/libcsdr.c b/libcsdr.c
index d06bb5d..436c589 100755
--- a/libcsdr.c
+++ b/libcsdr.c
@@ -2100,10 +2100,12 @@ void bpsk_costas_loop_cc(complexf* input, complexf* output, int input_size, bpsk
else error = iof(output,i)*qof(output,i);
s->dphase = error * s->alpha + s->iir_temp;
s->iir_temp += error * s->beta;
+ fprintf(stderr, " error = %f, dphase = %f, nco_phase = %f\n", error, s->dphase, s->nco_phase);
//step NCO
s->nco_phase += s->dphase;
while(s->nco_phase>2*PI) s->nco_phase-=2*PI;
+ while(s->nco_phase<=0) s->nco_phase+=2*PI;
}
}