The electron proton (e-p) instability has been observed in many proton accelerators. It will induce transverse beam size blow-up, cause beam loss and restrict the machine performance. Much research work has been done on the causes, dynamics and cures of this instability. A simulation code is developed to study the e-p instability in the ring of the China Spallation Neutron Source (CSNS).