Synthesis and decay of carbon-14
Carbon-14 synthesis happens in the upper atmosphere
A cosmic ray particle can knock out a neutron from the nucleus of an oxygen or nitrogen atom in the air.


If this neutron happens to collide with the nucleus of a (normal) nitrogen-14 atom then it can be absorbed and a proton is emitted leaving carbon-14.
Carbon-14 decays back to nitrogen-14
Carbon-14 has too many neutrons to be stable. After some time a neutron changes into a proton, emitting a beta particle. This turns it back into nitrogen-14.