NMEA2.bas

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

NMEA2.bas

Post by gramo » Thu Jul 29, 2010 11:24 am

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!
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Thu Jul 29, 2010 9:04 pm

Thanks Gramo!

Post Reply