Generation of entangled states and error protection from adiabatic avoided level crossings