I think my digital PLL is almost ready, but I've encountered this problem and I don't know what might be causing it, so I'd appreciate if you could help.

I'm using the DPLL in a Costas loop. It seems to work fine but whenever the message crosses zero, lock is lost. After that, it ends up locking again. You can see here:

[![enter image description here](https://i.stack.imgur.com/FKQF2.png)](https://i.stack.imgur.com/FKQF2.png)

Input to the Costas loop is:
$$
x(t) = m(t)cos(2\pi f\_ct+\theta\_{in})
$$
$$
m(t) = cos(2\pi f\_mt)
$$
where $f\_m << f\_c$

Not sure if this is a known phenomenom (it probably is) but I haven't been able to find anything related. It'd be nice if you could point out what's going on and/or how to fix the temporary loss of lock?

One way I've managed to get it "working" consisted of squaring the message signal (although phase error rises a bit when message goes near zero), but I don't wish to square it so that wouldn't be of use to me.

This is the Costas loop I'm implementing for this test:

[![costas loop](https://i.stack.imgur.com/nMiFl.png)](https://i.stack.imgur.com/nMiFl.png)