When were medieval castles start to be built?

around about 1100 to defend their land against raiders and other enemies