I don't know how to programm efficently on controllers.
The biggest lesson I have learned over the years is to code with a goal to never code it again: whenever you write a piece of code, always think about how you can write it so that it can be reused later for a different project.
This. The amount of people that blob some code into a single file, pray for it to work, and never look at it again. Is way too high.
The code becomes unmaintainable and only the original writer can make something of it for the next ~2 months.
Any time later it will be cheaper to just start over. Hours are not free.
But to learn code there is only 1 thing you can do: Read code. Other peoples code.
Find reputable C libraries and project, and read the code. See what they are doing, recognize the architecture.