Maybe half the time that code evolves into an API/HAL that the final application will use. Many times it also becomes code for manufacturing test (burn in with the test code, then reflash with final production firmware right before boxing)
Starting out with application code on top of a brand new design will lead to madness. Take it in smaller steps.
I just couldn't get it to work. While trying to understand what was going on, I literally went down the levels of abstraction until I was measuring voltages with an oscilloscope. Turns out that one of the resistors on the board wasn't properly soldered.
It was a good journey from software to all the way down to hardware, but frustrating. Nowadays I develop web applications and I'm happy that I don't have to deal with this kind of problem anymore.
(Okay, that equipment is also kinda expensive, and retains its value far longer than old computers... But even new stuff has gotten a lot cheaper than it used to be.)