A pacemaker implantable in a chamber of a patient's heart is configured to produce a filtered cardiac electrical signal by filtering a raw cardiac signal by an adjustable filter of a sensing module of the pacemaker. The sensing module is configured to receive the raw cardiac electrical signal comprising R-waves, T-waves and P-waves via electrodes coupled to the sensing module. The pacemaker is further configured to determine if the T-waves are distinct from the P-waves in the filtered cardiac electrical signal and adjust the filter to increase a difference between a feature of the P-waves and a feature of the T-waves in the filtered cardiac signal when the T-waves are not distinct from the P-waves.