Oh and speaking of mistakes .....
On friday after spending most of the day testing stuff to be posted out this week, I had a spare hour to have a play with one of the new products I'm designing.
I'd been working on some serial code for a while in MPLAB and it all seemed to be working fine. I thought I'd bung it on one of the processors and give it a test in real life.
Plugged the 18F1320 into the breadboard, powered it up and got garbage on the RS232 terminal. Then it reset itself and repeated this.
I then remembered to put the 0.1uf bypass cap across the power pins and the resets stopped. It worked as it should but the characters I was expecting were not appearing on the terminal.
I then tried different baud rates on the terminal, a different Serial port, a couple of USB-RS232 adapters and still got the same results.
Double checked the code - it all seemed fine.
Turns out I had a 4Mhz crystal on the circuit rather than the 10Mhz one I thought I was using. With HSPLL enabled, this meant I was running at 16Mhz rather than 40Mhz.
Sometimes its the simplest of things that throws you.