A feedback scheme for preparation of photon number states in a microwave cavity is proposed. Quantum Non Demolition (QND) measurement of the cavity field provides information on its actual state. The control consists in injecting into the cavity mode a microwave pulse adjusted to increase the population of the desired target photon number. In the ideal case (perfect cavity and measures), we present the feedback scheme and its detailed convergence proof through stochastic Lyapunov techniques based on super-martingales and other probabilistic arguments. Quantum Monte-Carlo simulations performed with experimental parameters illustrate convergence and robustness of such feedback scheme.