Page 1 of 1

NMEA2.bas

Posted: Thu Jul 29, 2010 11:24 am
by gramo
I recently had a couple of issues with Davids NMEA.bas module - it was stomping on shared RAM registers.

Not being familiar with his programming approach, I created my own NMEA module. It is interrupt driven, but will wait for manual intervention between sentence parsing. It's quite easy to use and can be configured to operate in either the high/low interrupt vector:

Code: Select all

// define device, clock and disable MCLRE
Device = 18F2520
Clock = 32
Config MCLRE = Off
 
Include "InternalOscillator.bas"    // this module configures the internal oscillator to operate at 32Mhz from the get-go
Include "NMEA2.bas"
Include "USART.bas"                 // the USART module is required to configure the baud rate
Include "Convert.bas"
 
Dim tmpField As String(12)
Dim i As Byte
 
 
// main program start...
USART.SetBaudrate(br38400) // configure USART                   
NMEA2.Initialise()         // intialise NMEA2 module
 
// main program loop
While True
    NMEA2.NextSentence("GPRMC")
 
    Repeat
    Until NMEA.NewItem        
 
    For i = 0 To NMEA.FieldCount
        If GetField(i,tmpField) Then
            USART.Write("GPRMC Field ",DecToStr(i), " = ",tmpField,13,10)
        EndIf    
    Next
 
    NMEA.NewItem = False
Wend
Here's a quick simulation of a NMEA sentence being sent to a PIC with the above program:

Image

The user module is hosted at Digital DIY and in the SF Wiki. As always - I'm open for feedback and tips!

Posted: Thu Jul 29, 2010 9:04 pm
by Steven
Thanks Gramo!