Why is this in installation and troubleshooting?
I could see in programming questions, so you could ask why it behaves like this. It is not useful as a reference for others as is, because you haven't done the necessary legwork to figure out why you get different behavior depending on the ordering of those register writes. Without knowing the cause, you don't know in what situations the order of those register writes will matter, nor have a system to determine what the right order is.
The reason for it not working doesn't jump out at me - but since I have no freaking clue what the rest of your code is doing or how it fails, I hardly feel like I'm in a good position to provide such.