In 1800, he was sent to Spain to follow his military studies in Madrid, where he remained until 1802.