Quote Originally Posted by bethr View Post
It's alive !!
WooHoo!

I'm wondered why this bit must be set in hi speed if my bps is low ! (4800 bps)
With a 4mhz OSC, I wouldn't consider 4800 "low".

In the datasheet there's a couple tables that show the baud rates vs. OSC freq with BRGH either 1 or 0. With BRGH=0 @ 4mhz, the highest baudrate in the table is 2400. With BRGH=1 it's 19200.

It may still work with BRGH=0, but it's close to the edge, so why not just make it BRGH=1.

I think the HSER_CLROERR 1 may have had the biggest effect.
The GPS will just spit out the data at regular intervals. It doesn't wait for the PIC to be ready. And at 4800 baud it can send a byte every 2ms. So when the program sits in a 500 ms pause, it may receive a couple hundred bytes before the program gets around to looking at the data. There's only a 2 byte buffer in the USART so it causes an Overflow that must be cleared before it will start receiving data again.

BTW currently I'm not using UART interrupts, but . . .
. . . what if . . .

I enable it ?, this give more reliable data incoming form the GPS line ? or it can be dangerous for the RTC health ?
HSERIN is not compatible with USART interrupts.
You would need to parse the incomming data 1 byte at a time with your own handlers.

It's much easier to use HSERIN.

hth,