The increased functionality of implantable devices, including pacemakers and defibrillators, makes it necessary to automate tasks such as capture threshold search and signal amplitude measurements in order to relieve the physician of those duties. The invention presents a new approach for the capture threshold detection for atrial as well as ventricular pacing. The suggested algorithm analyzes the change of the signal morphology of the ECG to discriminate between captured and non-captured events. The algorithm comprises two phases, a reference event definition phase and an event classification phase.