if you are using the 16 bit baudrate generator
BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
then the baud rate is set using SPBRGHx and SPBRGx
settingis only half the jobCode:SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08%
if you are using the 16 bit baudrate generator
BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
then the baud rate is set using SPBRGHx and SPBRGx
settingis only half the jobCode:SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08%
Warning I'm not a teacher
Dear all,
i did the following....
It works the part of a baudrate change, when i send the command to the gpsCode:'*-----------------------------------------------------------------------------| '* | --------------------- | | '*----------------------- | EUART 1 Configuration | --------------------------| '* | --------------------- | | '*-----------------------------------------------------------------------------| RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 'CLROERR = 1 ' Clear overflow automatically SPBRG = 160 ' 38400 Baud @ 64MHz, -0,08% SPBRGH = 1 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator '*-----------------------------------------------------------------------------| '* | --------------------- | | '*----------------------- | EUART 2 Configuration | --------------------------| '* | --------------------- | | '*-----------------------------------------------------------------------------| RCSTA2 = $90 ' Enable serial port & continuous receive TXSTA2 = $24 ' Enable transmit, BRGH = 1 'CLROERR2 1 ' Clear overflow automatically SPBRG2 = 130 ' 9600 Baud @ 64MHz, -0,02% SPBRGH2 = 6 BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator '------------------------------------------------------------------------------| '-----------sent a sentence to gps, this is not working at the moment----------| '------------------------------------------------------------------------------| ' When the GPS Module is POWERED ON, then the following sentenses are received. ' $PMTK011,MTKGPS*08 ' $PMTK010,001*2E ' $PMTK010,002*2D pause 800 HSEROUT2 ["$PMTK251,38400*27",13,10] ' 38400 boundrate, check MTK manual configuration pause 800 SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08% Pause 500 HSEROUT2 ["$PMTK220,100*2F",13,10] ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz pause 100
but i think the following it goes to GPS but for some reason is not set.Code:HSEROUT2 ["$PMTK251,38400*27",13,10] ' 38400 boundrate, check MTK manual configuration pause 800
Code:HSEROUT2 ["$PMTK220,100*2F",13,10] ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz pause 100
When you switch the baudrate you have to set both SPBRG2 and SPBRGH2.
Try:Code:SPBRG2 = 160 ' 38400 Baud @ 64MHz, -0,08% SPBRGH2 = 1 Pause 500
It worked!!! I will post later on what i have done up to now. Maybe i need to set up a small indication when those commands are set. So i know that program is working up to that stage.
This is the code for changing the baudrate to GPS and the hz rate at 10Hz at the NMEA data.
Code:'*-----------------------------------------------------------------------------| '* | --------------------- | | '*----------------------- | EUART 1 Configuration | --------------------------| '* | --------------------- | | '*-----------------------------------------------------------------------------| RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 'CLROERR = 1 ' Clear overflow automatically SPBRG = 160 ' 38400 Baud @ 64MHz, -0,08% SPBRGH = 1 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator '*-----------------------------------------------------------------------------| '* | --------------------- | | '*----------------------- | EUART 2 Configuration | --------------------------| '* | --------------------- | | '*-----------------------------------------------------------------------------| RCSTA2 = $90 ' Enable serial port & continuous receive TXSTA2 = $24 ' Enable transmit, BRGH = 1 'CLROERR2 1 ' Clear overflow automatically SPBRG2 = 130 ' 9600 Baud @ 64MHz, -0,02% SPBRGH2 = 6 BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator '------------------------------------------------------------------------------| '-----------sent a sentence to gps, this is not working at the moment----------| '------------------------------------------------------------------------------| ' When the GPS Module is POWERED ON, then the following sentenses are received. ' $PMTK011,MTKGPS*08 ' $PMTK010,001*2E ' $PMTK010,002*2D 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 ["$PMTK220,100*2F",13,10] ' 100(millisecond)=0.1(sec)-->1/0.1= 10Hz pause 100
Dear all,
i need you help.
After removing all the DEFINEs and use only the following
and for changing the baudrate and the frequency for the Second Serial,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
I found out that on SERIAL TERMINAL on the computer of course i see the data coming from the GPS but unfortunately when i connect an LCD to PIC using the first Serial, the data cannot be displayed.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
It seems that when i use
the data cannot be read from the GPS to the RX of the PIC.Code:HSERIN2[wait("$GPRMC")
I tried to check if there is a problem with the LCD, but i can send text to the LCD.
I tried to check and use only the DEFINEs with 9600 because the default for the GPS is 9600 and it worked.
so when i do not use the defines, it looks like that RX port on the PIC doesnt work.
Could you please help?
I don't know about other members of the forum, but I got confused.
Best throw in both codes that work and don't work.
Do they compile OK?
Are you sure about your connections?
Ioannis
Bookmarks