We show that topological equivalence classes of circles in a two-dimensional square lattice can be used to design dynamical decoupling procedures to protect qubits attached on the edges of the lattice. Based on the circles of the topologically trivial class in the original and the dual lattices, we devise a procedure which removes all kinds of local Hamiltonians from the dynamics of the qubits while keeping information stored in the homological degrees of freedom unchanged. If only the linearly independent interaction and nearest-neighbor two-qubit interactions are concerned, a much simpler procedure which involves the four equivalence classes of circles can be designed. This procedure is compatible with Eulerian and concatenated dynamical decouplings, which make it possible to implement the procedure with bounded-strength controls and for a long time period. As an application, it is shown that our method can be directly generalized to finite square lattices to suppress uncorrectable errors in surface codes.