Higher angular resolution is required to telescope for scientific observing. Fabricating a large aperture monolithic mirror is limited by existing manufacturing technology, so segmented mirror has become a trend. But it also introduces the problem of co-phasing the segments to make the primary mirror be diffraction-limited. Here we study a new phasing technique to phase two major phasing errors which significantly affect the status of the segmented primary mirror, piston and tip-tilt. As all the segments can be described in pairs, two segments per pair, we assume that one is the reference, the other is the segment with random piston and tip-tilt. According to this setting and refer to Fourier Optics, an analytical model is built up, then deduce the point spread function(PSF) and optical transfer function(OTF). In the chromatic situation, two secondary peaks of the modulation transfer function(MTF) are sensitive to the piston difference between the two segments of one certain group. While the phase transfer function(PTF) is sensitive to tip-tilt in both monochromatic and chromatic situation. Our detection technique only needs a set of hardware and it can realize the detection at one go. We first detect tip-tilt and minimize it close to zero, then detect piston. To show the potential of this technique, we numerically simulate conditions on James Webb Space Telescope(JWST), simulation results prove that we can fine phase initial tip-tilt 2 arcseconds to an accuracy of 0.58mas. The allowed detection range of piston can be one-half of the coherence length and the accuracy of the piston detection can reach λ⁄100 RMS for piston. The total method has achieved a detection of phasing errors over a wide dynamic range with a high precision.