Robert, many thanks for the link.
I've entered the parameters for 9600 baud, with a osc of 20 and get the resulting code
Code:
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 8 ' 9600 Baud @ SPBRGH = 2
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 8 ' 9600 Baud @ -0.03%
SPBRGH = 2
However I still get an "unable to open comport" message when using the serial comm tool in Microcode studio..
I'm using a USB to 5v TTL serial cable that is based on a prolific chipset, and to test this I loaded up an example code I had from a previous project, which relied on a different crystal (12 mhz) and then used the PPL multiplier to up the OSC to 48. This code simply echoed what is sent via the TX box and worked fine, so the physical communication between PC and PIC is fine. The only drawback of using the 12mhz xtal and the OSC48 is that the LCD, and temp sensor comms are screwed. I really need the serial coms to work with a OSC of 20 and a 20mhz xtal as the rest of the code (temp sensor, RTC etc ) all work fine at these settings.
Any ideas ?
Bookmarks