In an accelerated expanding universe, one can expect the existence of an event horizon. It may be interesting to study the thermodynamics of the Friedmann-Robertson-Walker (FRW) universe at the event horizon. Considering the usual Hawking temperature, the first law of thermodynamics does not hold on the event horizon. To satisfy the first law of thermodynamics, it is necessary to redefine Hawking temperature. In this paper, using the redefinition of Hawking temperature and applying the first law of thermodynamics on the event horizon, the Friedmann equations are obtained in f(R) gravity from the viewpoint of Palatini formalism. In addition, the generalized second law (GSL) of thermodynamics, as a measure of the validity of the theory, is investigated.