OOPs.
I just looked up the 188 from your SERIN2 statement.
That's 4800 baud TRUE levels.
You can hook it up to the USART's RX pin. No transistor needed.
hth,
OOPs.
I just looked up the 188 from your SERIN2 statement.
That's 4800 baud TRUE levels.
You can hook it up to the USART's RX pin. No transistor needed.
hth,
DT
Thanks by answer Skimask, Darrel !
you both Are right, there is no interfacing conflicts, but unfortunately I always get the ' no gps ' string on the LCD (with or without running the RTC), I mean, I have made changes for using Hserin instead serin2,
Code:'''''''''''''' INCLUDES '''''''''''''''''''''''''''''''''''' DEFINE OSC 4 INCLUDE "DT_INTS-18.bas" INCLUDE "ReEnterPBP-18.bas" INCLUDE "Elapsed_INT-18.bas" INCLUDE "LCDPICDEM2.BAS" ' it runs on PIDEM2 PLUS Board DEFINE HSER_TXSTA 20h DEFINE HSER_RCSTA 90h DEFINE HSER_BAUD 4800 ''''''''''''' VARIABLES '''''''''''''''''''''''''''''''''''' j var byte rmc var byte[100] ' this gets RMC data led1 var portb.2 b0 var byte adcon1 =$07 trisa.2 = 0 trisa.4 = 1 trisb.1 = 1 trisb.2 = 0 trisb.0 = 1 trisc.2 = 0 trisc.7 = 1 porta.2 = 0 gps var portb.1 spk var portc.2 ''''''''''''' CODE '''''''''''''''''''''''''''''''''''' init: ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ClockCount, PBP, yes endm INT_CREATE ENDASM @ INT_ENABLE TMR1_INT GOSUB ResetTime GOSUB StartTimer hours = 11 : minutes = 30: seconds = 0 Start: LCDOUT $FE,1 ' Initialize LCD PAUSE 200 lcdout $fe,2,"Starting ..." : pause 500 Main: Hserin 1500,no_gps,[wait("MC"),str rmc\15\10] '15 bytes only for testing () wait for RMC message lcdout $fe,$c0,"Time : ",dec2 hours,":",dec2 minutes,":",dec2 seconds lcdout $fe,2,"$",str rmc\15 :pause 500 ' these are the bytes as captured ! goto main no_gps: lcdout $fe,1,"No Gps stream " lcdout $fe,$c0,"Time : ",dec2 hours,":",dec2 minutes,":",dec2 seconds goto main '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
currently for debug I'm using an GPS software simulator:
and I'm sure that it works, this is a debug rs232 window (hyperterm)
that was taken on Sub-DB9 connector of the picdem2 board
there is something missing in the set-up hardware UART ???
Thanks again !
Try it like this...Code:DEFINE HSER_TXSTA 24h ' BRGH=1 DEFINE HSER_RCSTA 90h DEFINE HSER_BAUD 4800 DEFINE HSER_CLROERR 1 'Hser clear overflow automatically
DT
It's alive !!
it works Darrel, I'm wondered why this bit must be set in hi speed if my bps is low ! (4800 bps)
and now it looks run pretty ! (with RTC running ), look this:Code:bit 2 BRGH: High Baud Rate Select bit Asynchronous mode: 1 = High speed 0 = Low speed
Now, I'll keep it running for a while, I hope the RTC doesn't have long-delays. any-way as you said, always there is way to update ths RTC register with GPS ones !!
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 ?
![]()
Last edited by bethr; - 2nd July 2008 at 01:47.
WooHoo!
With a 4mhz OSC, I wouldn't consider 4800 "low".I'm wondered why this bit must be set in hi speed if my bps is low ! (4800 bps)
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.
HSERIN is not compatible with USART interrupts.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 ?
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,
DT
Yes you're Right, I think that on this way the gps clock work well, there is no problem with it, I have it running & all looks nice !
The program doesn't anything important (just led blinking), and when BTN rb0 is pushed, it gets info from GPS module and update my RTC registers just as i wanted !
I've had to replace my broken LCD also !!Code:'BETHR '''''''''''''' INCLUDES '''''''''''''''''''''''''''''''''''' DEFINE OSC 4 INCLUDE "DT_INTS-18.bas" INCLUDE "ReEnterPBP-18.bas" INCLUDE "Elapsed_INT-18.bas" INCLUDE "LCDPICDEM2.BAS" ' it runs on PIDEM2 PLUS Board DEFINE HSER_TXSTA 24h ' BRGH=1 DEFINE HSER_RCSTA 90h DEFINE HSER_CLROERR 1 ' Hser clear overflow automatically DEFINE HSER_SPBRG 51 ''''''''''''' VARS '''''''''''''''''''''''''''''''''''' led var Portb.2 timeh var byte timem var byte times var byte day var byte mon var byte yr var byte stat var byte gps var Portb.1 TRISB.2 = 0 TRISB.0 = 1 Adcon1 = $07 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' init: ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ClockCount, PBP, yes endm INT_CREATE ENDASM @ INT_ENABLE TMR1_INT Gosub ResetTime Gosub StartTimer hours = 12 'after reset we always star @12:00:00 Start: lcdout $fe,1,"GPS Clock " Pause 500 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Main: While 1 'do something [ something more useful than this :-) ] While (portb.0=1) Toggle led Lcdout $fe,2,"Date : ",dec2 day,47,dec2 mon,47,dec2 yr Lcdout $fe,$c0,"Time : ",dec2 hours,":",dec2 minutes,":",dec2 seconds Pause 200 Wend ' if i press rb0 btn update my RTC Gosub Update_rtc Wend ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' SUBS '''' Update_rtc: 'look 4 stream lcdout $fe,1,"Updating..." Hserin 500,no_gps,[WAIT("MC,"),dec2 TIMEH,dec2 TIMEM,dec2 TIMES,SKIP 5,_ STAT,skip 30,dec2 day,dec2 mon,dec2 yr] 'check 4 Valid GPS if so, then update my RTC if stat = "A" then hours=timeh - 5 : minutes = timem: seconds = times 'no gps so don't update else lcdout $fe,1,"Bad Fix" : pause 500 endif return 'np gps or bad sintax no_gps: lcdout $fe,1,"No Gps stream" : pause 500 return ''' END SUBS ''''
BIG TNX !
Hi there Bethr,
I am looking at purchasing a garmin LVS gps for a robot project and I was just wondering what kind of gps you are using? Cost? etc....
Padawan-78
Bookmarks