Hi Guys and Gals

Some years ago, with the help of DT and Henrik I worked on a 4 channel thermostat project which I'm now looking at upgrading to incorporate some new sensors and options. One of the problems that I'm still trying to resolve is the serial communications.

I've used PIC Multi Calc to give me the settings and defines for the serial port settings on both cases. I've also written a PC application in Liberty Basic to read and update the settings, but also tried communications by sending the commands via the terminal in MCS.

OK - I'm using an 18F4580 with an OSC val of 48 in both cases. Inserting a 12Mhz crystal in the development board with the USART settings to
Code:
'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER_SPBRG 25  ' 115200 Baud @ 48MHz, 0.16%
'SPBRGH = 0
'BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
Compile and load into the PIC and launch the application, which first checks the comm ports available and then scans for a response from the PIC by sending a "C" to the PIC which then responds with "R" and then on confirmation that it found the controller launches the application and sends "R again which instructs the PIC to send the data stream. This works fine when the 12 Mhz crystal is in place. I can also launch the serial monitor in MCS and replicate receiving the data stream.

But as I really wanted to use a 20 Mhz crystal as it make other processes run faster which in a PID thermostat is my preference, I get "no controller found" when the PIC is polled from the application. In the serial monitor it registers connection with the com port (I'm using a USB/ Serial module from Mikroelectronika) but again fails to respond to the manual TX codes. Here's the revised USART settings that the multicalc application gives
Code:
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 25  ' 115200 Baud @ 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically

RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 25  ' 115200 Baud @ 0.16%
Now I'm assuming that the reason it works with the 12 Mhz xtal is that the 48 OSC value is divisible by 4 to equal the crystal value. Where as using the 20 Mhz xtal, the OSC value is not directly divisible. So I changed the OSC value to 40, recalculated the USART settings for a 40 OSC and tried that, but to no avail.

Any suggestions on how to get this working with a 20 Mhz xtal