Cannons are the primary defensive weapon against the Titans since they first attacked humanity. The ones in Attack on Titan are breach loading cannons, which means they are loaded from the back. These weapons take 40-60 seconds to reload and are normally mounted on rails along the major walls to slow down Titan advancements. Once the combo of the sword and 3D maneuvering equipment was made the primary weapon for humanities survival, another role was given to the cannon as a support weapon to the soldeirs fighting in the streets. Often inaccurate and long to reload it is not an ideal weapon. However it is still essential to successful defence against the Titans.
The cannon comes in two forms: The rail mounted fixed gun version and the mounted on a two wheeled undercarrage field gun version. The fixed gun is substantially larger than the field gun allowing it to do more damage. The cannons are capable of firing HE (high explosive), canister, and solid steel rounds. The charge and the projectile are tied together and loaded into the cannon as one piece to save time compared to loading it seperately.
There is one other type of cannon shown in Attack on Titan: The harpoon cannon. The harpoon cannons job is to stop Titans so they can be captured or killed easier. They are intended to be used in large numbers. This cannon was invented by Hanji Zoe. It is a wooden barrel with 7 steel barrels inside it and is normally mounted in a cart making a battery. Each steel barrel contains a harpoon with a cable coiled behind it. when shot, it launches the harpoons into its target with one end of the cable attached to the back of the harpoon and the other end still attached to the cannon.
It is currently assumed that only the garrison [stationary guards] use the cannons but in the anime one of the characters ask if they hear cannon fire outside trost but the scouting legion is never seen using the normal cannon however as mentioned above they do use harpoon cannons.
Cannons can kill titans by hitting them in the nape or "shelling" them to death by shooting one titan with 4 or 5 cannons