Recently the new model for the generation of strong large scale magnetic fields in neutron stars, driven by the parity violating interaction, was proposed. In this model, the magnetic field instability results from the modification of the chiral magnetic effect in presence of the electroweak interaction between ultrarelativistic electrons and nucleons. In the present work we study how a nonzero mass of charged particles, which are degenerate relativistic electrons and nonrelativistic protons, influences the generation of the magnetic field in frames of this approach. For this purpose we calculate the induced electric current of these charged particles, electroweakly interacting with background neutrons and an external magnetic field, exactly accounting for the particle mass. This current is calculated by two methods: using the exact solution of the Dirac equation for a charged particle in external fields and computing the polarization operator of a photon in matter composed of background neutrons. We show that the induced current is vanishing in both approaches leading to the zero contribution of massive particles to the generated magnetic field. We discuss the implication of our results for the problem of the magnetic field generation in compact stars.