As soon as you put the term "code of chivalry" from your mind, everything becomes much easier.
The modern word "chivalry" comes from Old French chevalerie, meaning the behavior of knights. It first appears in the twelfth century as an ideal to which knights might aspire. But from the beginning it was highly contested and contradictory, which is why it is impossible to speak of a single "code."
We know about twelfth-century chivalry primarily from the epics and romances that knights enjoyed. Every author portrayed chivalry somewhat differently, suggesting that there was no agreement as to what chivalry might entail. In addition, the authors of the epics put their heroes into situations where even the best and most chivalrous could not follow all of chivalry's conflicting demands.
In the "Song of Roland," for example, one of the first epics, the hero Roland is reckless and brave, unwilling to ask for backup when in a desperate battle, and ends up dead, having allowed half his king's army to be destroyed.
"Chivalry" originally was used to mean battlefield virtues, courage and strength, but it quickly became merged with "courtesy" (courtoisie in Old French), meaning knowing how to behave well at court, being polite, tidy, and restrained. By the time Christian virtue and deference to ladies were added in, the mix was hopeless.
After all, how can someone, at the same time, be a ferocious fighter, a meek Christian who turns the other cheek, someone who is lively and entertaining while delicately stealing a kiss (or something more), and a refined, learned man who is always careful about his clothes and appearance?
By the fourteenth century, actual "manuals" of chivalry were being written which just complicated the situation even more with enormous long lists of things to do and not do. But knights clung to the ideal of chivalry, because by this time, the fourteenth century, their centrality in warfare was being superseded by cannons and footmen with pikes.
For more on knights, click here and here.
© C. Dale Brittain 2014