CAN ANYONE EXPLAIN THIS?

??
For the last 12 months my Mk2 2200CDi pinked badly especially going up hill. For about the same length of time, my battery had been weak (poss. a cell down) but would always be enough to start (although the starter turned slowly) the car and run all elec. systems.
Finally, the battery died completely and was re-newed. RESULT - no more pinking!
Why did a slightly weak battery cause pinking? Answers on a postcard please!
Ian D
(N.B. if your car pinks, make sure your battery is giving enough juice)