Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hi Eric,Hi C,
HSERIN uses the PIC's internal UART module,, SERIN is a software UART
Eric
'software UART receives data stream at 4800 baud and when code GGA is detected we capture 42 bytes
'in array a(42) then send these to the PC via hardware UART at 9600 baud
Hi,
I have not run your program.... yet.
I would advise you to use the HSERIN [ internal UART] module in your programs.
It will be easier to change the Baud rates etc, while you experiment.
Using the Serin means you will have write and debug all the software timing routines, which will a be pain and you will not gain any timing advantage.
If however, you need two or more RS232 inputs to your PIC, you have to use Hserin and Serin.
Why do you have such long Wait delays in your program.??
E
Hi E,hi,
Please post a complete a GGA string and any other strings you expect on the Serin PORTB.1
E
hi C,
I used the '$' to initiate the string test and capture, you will never have two NEMA strings being received at the same instant.
So test for the '$' character, save the whole string, then if required test for the GGA string, if valid process the string
If you only ever expect the $GPGGA section of the transmission on the serial input.?? Then parse out the N , E , M segments of the string
[tell me, where is your actual data string from and does have other string prefixes???]
Hi,
Looking at your application, I would do it this way.
Use the internal UART to read the NMEA string.
Set the Hserin, UART to Interrupt on receiving a character, go to to ISR [intr service routine], IF the Character is $ then read the remainder of the string into a buffer array.
IF the Buffer string has the prefix GPGGA then its the one you want.
IIRC the string terminated with a CR LF code.??
Once you have the full string, look at the Index Pointer of your buffer array to find the Nnnnnn, Eeeeee and Mmmm values and then process them.
You can use the TX output of the Hserout to talk to your PC
E
C'software UART receives data stream at 4800 baud and when code GGA is detected we capture 42 bytes
'in array a(42) then send these to the PC via hardware UART at 9600 baud
C
I was just repeating what you planned to do, ie;then send these to the PC via hardware UART at 9600 baud
So hardware UART reads the incoming data and the same UART sends the data to the PC
E
Hi E,C
I was just repeating what you planned to do, ie;then send these to the PC via hardware UART at 9600 baud
So hardware UART reads the incoming data and the same UART sends the data to the PC
E
hi C,
Dont worry about confusion, we all get that way at sometime.
Post your code when ready
E
'software uart receives data stream at 4800 baud And when code gga is detected we capture 42 bytes
'in array a(42) then send these to the PC via hardware UART at 9600 baud
'COPY and PASTE this string.
'$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47?
Define SIMULATION_WAITMS_VALUE = 1
Dim chr As Byte
Dim rxi As Byte
Dim txi As Byte
Dim start_code(2) As Byte 'enables scan of the last 3 characters received
Dim str1(42) As Byte 'save the data stream we need in here
Dim i As Byte
Dim j As Byte
Dim gga As Byte
Dim data As Byte
Dim latdeg As Byte
Dim latmin As Byte
Dim londeg As Byte
Dim lonmin As Byte
'> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >.
Define CONF_WORD = 0x3f41 'XTL
Define CLOCK_FREQUENCY = 4 'Changed from 12
AllDigital
'Define osc 4
CMCON = 7
OPTION_REG.7 = 0 'Enable Pull-Up's
Dim led_a2 As Bit 'PORTA.2 'flash per second
Define LCD_DREG = PORTB 'Port for LCD Data
Define LCD_DBIT = 4 'Use upper 4 bits of Port
Define LCD_RSREG = PORTA 'Port for RegisterSelect (RS) bit
Define LCD_RSBIT = 2 'Port Pin for RS bit (pin9)
Define LCD_EREG = PORTA 'Port for Enable (E) bit
Define LCD_EBIT = 4 'Port Pin for E bit (pin7)
Define LCD_BITS = 4 'Using 4-bit bus
Define LCD_LINES = 4 'Using 2 line Display
Define LCD_CHARS = 16 'ADDED
Define LCD_COMMANDUS = 2000 'Command Delay (uS)
Define LCD_DATAUS = 50 'Data Delay (uS)
'Define osc 4
CMCON = 7
OPTION_REG.7 = 0 'Enable Pull-Up's
TRISA = %00000000
TRISB = %01000000
'$GGA 1234
Lcdinit
Hseropen 9600
INTCON.GIE = 1
INTCON.PEIE = 1
PIE1.RCIE = 1
Hserout "Ready - await $", CrLf, CrLf
main:
Goto main
End
On Interrupt
Save System
PIR1.RCIF = 0
Hserin chr
If chr = "$" Then ' test for string start
rxi = 0
Endif
str1(rxi) = chr
rxi = rxi + 1
If chr = "?" Then 'test for temporary LF code
For txi = 0 To rxi
Hserout str1(txi)
If str1(txi) = "," Then Hserout CrLf ' a demo on how to break the string into chunks.!
Next txi
Endif
Resume
On Interrupt
Save System
PIR1.RCIF = 0
Hserin chr
If chr = "$" Then 'start
rxi = 0
Endif
str1(rxi) = chr
rxi = rxi + 1
If chr = "?" Then 'temp LF
For txi = 14 To 23
Hserout str1(txi)
Next txi
Hserout CrLf
For txi = 25 To 35
Hserout str1(txi)
Next txi
Hserout CrLf
For txi = 46 To 52
Hserout str1(txi)
Next txi
Hserout CrLf
Endif
Resume