This paper deals with the study of the rf cycle of the synchrotron of the Proton-Ion Medical Machine Study (PIMMS) hosted at CERN. The cycle comprises the adiabatic trapping, the acceleration and the rf gymnastics, both for protons and fully stripped carbon ions. The injection energy is 20 MeV for protons and 7 MeV/u for carbon. The maximum extraction energies are 250 MeV for protons and 400 MeV/u for carbon ions. The reserved time is less than 1 s, with a maximum magnetic field ramp of less than 3 T/s. The simulations show that the beam stays inside the aperture of the machine, and that there are no longitudinal losses. At the end of the cycle the beam is ready for extraction with a Dp/p of 0.4 %. The peak rf voltage is 3 kV and the frequency range is from 0.49 to 2.85 MHz