Hi,
Do a search for Pic Multicalc, it's very useful for setting up the defines etc. Entering an osc of 4Mhz and 3400 or 57600 it gives these values
You could try these values, however for running at a fast baud rate I would recommend using a 20Mhz crystal on the 16F877A with the following definesCode:DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 6 ' 38400 Baud @ 4MHz, -6.99% DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0 DEFINE HSER_SPBRG 0 ' 57600 Baud @ 4MHz, 8.51% DEFINE HSER_CLROERR 1 ' Clear overflow automatically
Code:@ __config _HS_OSC DEFINE OSC 20 DEFINE HSER_BAUD 115200 ' Hser baud rate DEFINE HSER_RCSTA 90h ' Hser receive status init DEFINE HSER_TXSTA 24h ' Hser transmit status init DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1.36% DEFINE HSER_CLROERR 1 ' Hser clear overflow automatically




Bookmarks