If you are using the internal osc you might want to setup the osccon register. I don't see it in your code.