In the following year he suffered a short imprisonment in Lisbon. In 1639 he was appointed colonel of one of the regiments raised for service in Flanders, and in June that year he took a leading part in defending A Coruña against a French fleet commanded by the archbishop of Bordeaux, while in the following August he directed the embarcation of an expeditionary force of 10,000 men when Admiral Oquendo sailed with seventy ships to meet the French and Dutch (A). He came safely through the naval defeat in the channel suffered by the Spaniards at the hands of Maarten Tromp, and on the outbreak of the Catalan revolt became chief of the staff to the commander-in-chief of the royal forces, and was selected to write an account of the campaign, the "Historia de la guerra de Cataluña", which became a Spanish classic.