1. I have the power line to the GPS controlled by the PIC. When I'm done with it, I turn it off to save power.
However, I'm finding that about 1 in 10 times, when I turn off the GPS, the PIC halts and has to be reset. I'm using the NMEA module.
It was halting nearly every time I turned off the GPS until I disabled the interrupt (made it public then called it from the main routine).
I also tried (and none worked):
- disabling the serial port altogether before shutting it down
- just turning off the EUSART2 interrupt: PIE3.5 = 0
- slowed speed from 32 MHz to 16 MHz - there is a silicon errata that says the chip may get errors accessing RAM above 32 MHz when using the PLL - no difference
- different combinations of disable interrupt, turning off GPS, delays in between each to see if things needed time to settle before going on to the next operation
- scoped the power and on/off lines to the GPS and PIC - no abnormal spikes/sags were noted
None of these measures offered a solution. Any ideas out there??
It would sure be nice to be able to have visibility of just where the program is going when it halts. Can anyone recommend a good method of debugging to see what's going on in the chip? I guess SF does not have a debug capability at all?
2. On another note, when the PIC does wake up and I want to turn the GPS on again, I call the NMEA.Initialize subroutine first (I made this public in the NMEA module, too), then turn on the GPS, and the GPS readings are picked up again in NMEA.bas's TNMEA structure. It's a bit unexpected, though, that NMEA.GetItem(NMEAItem) doesn't seem to trigger the USART2.Write debug statement to the serial port like it does the first time through the code before sleeping, but so far I've been able to get my data out of the structure. I don't have a lot of confidence in this, though, and am still testing it:
Code: Select all
If NMEA.GetItem(NMEAItem) Then GLCD.WriteAt(0,95,"in loop,index=",DecToStr(index)) USART2.Write("index",DecToStr(index),$0D) NMEA.GetField(NMEAItem,0,EUSART2_Input) If EUSART2_Input = "$GPRMC" Then GLCD.SSD1339.Rectangle(0,19,132,107,$FF,$FF,$FF,$FF) //clear middle of screen NMEA.GetField(NMEAItem, 2, lock_status) NMEA.GetField(NMEAItem, 3, lat) GLCD.WriteAt(0,20,"Lat: ", lat) NMEA.GetField(NMEAItem, 5, long) GLCD.WriteAt(0,33,"Long: ", long) NMEA.GetField(NMEAItem, 9, EUSART2_Input) GLCD.WriteAt(0,47,"Date: ", EUSART2_Input) NMEA.GetField(NMEAItem, 1, GMT_time) GLCD.WriteAt(0,60,"Time: ", GMT_time) NMEA.GetField(NMEAItem, 2, EUSART2_Input) NMEA.GetField(NMEAItem, 7, EUSART2_Input) GLCD.WriteAt(0,73,"Speed: ", EUSART2_Input) speed = EUSART2_Input speed = TrimToChar(speed,".") speed_int = StrToDec(speed) EndIf EndIf