Stone Is Poor Cover From Modern Weaponry
The main problem with stone is that it tends to splinter and cause really bad spalling. The best way to stop a modern tank round is not to stop it cold, but to absorb its impact. The best way to do this would be using dirt. My main profession in the USMC was anti-tank gunner, and as part of our training we received extensive instruction in what effects different impacts have on different kinds of armor. The best way to stop a high velocity sabot round, or high explosive round from a modern tank would be to try to catch the impact or detonation and distribute it evenly across a wide area, and for this purpose dirt would be extremely effective.
So using medieval tech to stop sustained fire from a modern main battle tank I would retrofit my normal castle walls. I would build a sturdy log palisade about 15 feet in front of the stone wall and fill the gap between with packed earth. Densely packed clay would be best, and it would work even better if it were thoroughly saturated with water. The wooden log palisade is simply there to contain the packed earth, the packed earth absorbs the impact or detonation and the stone wall directs the blast back outwards, or catches the impact from the high velocity sabot that has been substantially slowed from its journey through the packed earth. Bear in mind that this is not going to stop a series of 10 impacts in the exact same spot, but theoretically the wall itself could probably sustain a dozen or so direct impacts along it before the earth and wood were blasted away enough to expose the stone wall. This arrangement could probably sustain many many impacts from high velocity sabots, but high ex would blow away enough dirt that after a while it would begin to fall apart. If more time was available the outer wall could be made of stone but this is a retrofit that is going to take medieval construction techniques years to build, whereas the wooden palisade retrofit on an existing castle could theoretically be accomplished in months.
A castle wall made of stones and mortar is going to very rapidly be blasted away by either sort of round. The issue is that each impact turns a substantial portion of said stones into more shrapnel. Modern day fortifications are made from steel reinforced concrete, a pile of dirt, and more reinforced concrete. which is then usually buried again for this same purpose. Here is an example of some bunkers that the Serbians built for the Kuwaitis and promised would "indestructible." Obviously this was not the case, but it is an excellent example of modern bunker construction utilizing the principles that I suggested. This bunker would have been able to weather sustained tank fire like you speak of, unfortunately for it's Iraqi occupants it could not sustain an american 2,000 pound bomb. (The Kuwaitis are still SUUUUPER pissed at the Serbians that we destroyed their "indestructible" bunkers after they were occupied by Iraqi's.)