Pause with Start, then hold L and enter A, X, B, B, Y. You will hear a confirmation sound, and invincibility is on.
The catch is that it does not stick. Every time you finish an adventure you have to enter the code again, so if you are working through the game it is worth remembering the sequence rather than hunting for it each time.