The cause of potential barrier in the p n junction is
due to diffusion majority charge carriers cross the junction and made p types atom -ve ions and n type atoms + ve ions near the junction produces the depletion layer which prevents further diffusion