There were actually multiple countemeasures that were used, and should make an appearance, it's just that so far no one has been able to fix the Battle AI or BAI so it can cope with them, let alone stakes. Too bad really as they are all variations of one another.
Caltrops were specially made and inexpensive raised spikes which most often hurt cavalry as they dashed through the fields and came in contact with them.
| Caltrops |
 |
These are of course not medieval ones, but you get the idea how cheaply a blacksmith could make them.
| Stakes |
 |
Ditches dug the night before to causes stumbling areas for horses.
The Cheval de frise used up to the civil war and of course replaced by barbed wire and razor wire.
| Cheval de frise |
 |
I'd like to see a less lethal version of the latter. A special gate could be constructed and this sans stakes could act as a barrier, slowing down cavalry and making them not killed, but vulnerable to spear attacks. That's why I'm testing if rams can do the trick by daisy chaining them prior to battle, lining them up horizontally in the front row prior to a defensive line, and seeing what cavalry do with them.
EDIT: Had to try. Made eight rams and a weak army and attacked the Scots. The Scots were twice as strong in unit values, but I used lots of puny levies and peasants. The Scottish general took the bait, started to charge and then milled around repelled by the quickly thrown together barrier. See the attached pic. The smarter remainder of the Scottish waited inside.