pause 10 is too little time.
Maybe you need to make this 1000.
Then check with a timer that it actually pauses every 1 sec confirming that osc is setup correctly.
Recently I had similar matter setting up system oscillator again with 4xPLL and was running slow. Richard got it and we are OK now.
Ioannis
Bookmarks