Ioanni,
thanks for your reply.
The problem is when i use the code to change on the fly as of the guys on the forum advice, without using the "DEFINE" word.
So using the registers like in the following code:
Code:
'RCSTA2 = $90 ' Enable serial port & continuous receive
'TXSTA2 = $24 ' Enable transmit, BRGH = 1
'DEFINE HSER_CLROERR2 1 ' Clear overflow automatically
'SPBRG2 = 130 ' 9600 Baud @ 64MHz, -0,02%
'SPBRGH2 = 6
'BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
and later in order to change the baudrate i use the following:
Code:
pause 800
HSEROUT2 ["$PMTK251,38400*27",13,10] ' 38400 boundrate, check MTK manual configuration
pause 800
SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08%
SPBRGH2 = 1
Pause 500
;HSEROUT2 ["$PMTK314,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0*29",13,10]
HSEROUT2 ["$PMTK314,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28",13,10]
pause 100
HSEROUT2 ["$PMTK220,100*2F",13,10] ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz
pause 100
The GPS gets the command and set correctly the new configuration.
So up to here we are fine. I checked this by using a Serial Terminal and i see that both Baudrate and frequency have changed.
That means that TX is working well, for the first command to the GPS
Code:
HSEROUT2 ["$PMTK251,38400*27",13,10] ' 38400 boundrate, check MTK manual configuration
pause 800
and changing on the fly the Baudrate the following command to GPS is working fine as well with the NEW baudrate.
Code:
HSEROUT2 ["$PMTK314,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28",13,10]
pause 100
HSEROUT2 ["$PMTK220,100*2F",13,10] ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz
pause 100
[/CODE]
Now what is the problem.
I used a uLCD to send the VTG and RCM data to the display as i have done in the past using both SEROUT and HSEROUT2 command (for the HSEROUT2 i used the following code with the "DEFINE" and worked well)
Code:
'DEFINE HSER2_RCSTA 90h ' Enable serial port & continuous receive
'DEFINE HSER2_TXSTA 24h ' Enable transmit, BRGH = 1
'DEFINE HSER2_CLROERR 1 ' Clear overflow automatically
'DEFINE HSER2_SPBRG 130 ' 9600 Baud @ 64MHz, -0,02%
'SPBRGH2 = 6
'BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
Now using the registers without the "DEFINEs" the RX on the PIC seems that it doesnt work, something like it is closed or cannot read data from GPS.
Forgot to mention that 2 hours now i have tried most of the different settings for the
Code:
BAUDCON2 = %xxxxxxxx
without any luck.
Bookmarks