This could be Spaceship Medic, a novel from 1970 by Harry Harrison.
A spaceship passenger liner, the Johannes Kepler, is hit by a meteor, and the radio is destroyed. The crew manage to cobble together a receiver and a low-power transmitter, but they were not able to contact Mars - the output power was too weak. The acting captain, the medical officer, came up with a plan:
‘Something can be done. I know, I read about it once, a book or
something like that, about the early days of radio. Something about
code . . .’
‘Sure,’ Sparks answered. ‘Code. They used to use it maybe a couple of
hundred years ago. We had it in history at radio school. Before they
could modulate a signal to carry a message they used to just blast it
out, then interrupt it in short or long bits in a regular kind of
code. I guess they had a special signal for every letter. Then at the
other end they would put it back into letters again.
By just blasting static, instead of modulating the signal, they could achieve higher powers. They also come up with the idea of asking Mars to confirm receipt of the message:
‘After the numbers send a simple message, just ask them if they can
understand the code so that we can send more detailed messages.
Tell them we can hear their voice transmissions, but will have to
answer in code.’
The full story is available from the Internet Library.