His first service was under Lord Cochrane (afterwards tenth earl of Dundonald) in the famous "Imperieuse," and no midshipman ever had a livelier apprenticeship to the sea.
During his two and a half years of service under Cochrane, the young midshipman witnessed more than fifty engagements, and had much experience of service on the coast of Spain in the early stage of the Peninsular War, in the attack on the French squadron in the Roads (April 1809) and in the Walcheren expedition.
A Brazilian squadron, under command of Lord Cochrane, attacked the Portuguese vessels, embarrassed with troops, and took several of them.
Its anchorage was used by Lord Cochrane in 1820 during his attacks on Callao; it was the landing-place of an invading Chilean army in 1838; it was bombarded by the Chileans in 1880; and in 1883 it was the meeting-place of the Chilean and Peruvian commissioners who drew up the treaty of Ancon, which ended the war between Chile and Peru.
For three years after the peace of Amiens in 1802 the colony enjoyed uninterrupted calm, but in 1805 it was only saved from falling into the hands of the French by the timely arrival of Admiral Cochrane.