Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ATMEGA128 can't read GPS Holux GR-87

Status
Not open for further replies.

tarose78

Junior Member level 2
Joined
Jul 22, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,441
Hi all,

Now I am working on Atmega128 to receive GPS Data from Holux GR-87.
Connected using this init code.
Code:
// USART1 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART1 Receiver: On
// USART1 Transmitter: On
// USART1 Mode: Asynchronous
// USART1 Baud rate: 4800

UCSR1A=0x00;
UCSR1B=0x18;
UCSR1C=0x06;
UBRR1H=0x00;
UBRR1L=0x8f;

I know the GPS should return NMEA sentences, something like $GPRMC and others.
But, the Atmega128 is getting different sentences.
These are the code returned from the GPS and Received by Atmega128.
Code:
read: GPS parser
read: GP1,,09,T$GP1,,09,T$GP1,,09,T$GP1,,09,T$GP1,,AE,1,,01,,0090T$GP1,,09,T$GP1,,09,T$GP1,,09,
read: $GP1,,09,T$GP1,,AE,1,,01,,0090T$GP1,,09,T$GP1,,09,T$GP1,,09,T$GP1,,09,T$GP1,,AE,1,,01,,00

I tried to change the baudrate, but 4800 is the best so the sentences is readable by human.
I connect Pin PD2 directly to TX pin on GPS.


I dont know what else to check.
Please help...
 
Last edited:

Have You tried reading GPS data directly at your PC by connecting your GPS to PC through RS232.?
 

Hi salman, thanks for reply.

I did tried that, Connected directly from gps to PC.

It is normal NMEA has returned ( $GPRMC and others).

I am guessing there is something needed to make Atmega128 can read GPS normally.
 

Well then you have to post your complete code in order to let us identify the bugs, if any, exist in it.
 

Well, I tried to change to MCU. I guessed there is a problem with the code of Atmega128.
Now I am using Atmega32 programmed using USBASP with winAVR, but no crystall attached. Perhaps using internal Crystall.

Code:
#include <avr/io.h>
#include <util/delay.h> 
#define USART_BAUDRATE 4800
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

void usart_init();
unsigned int usart_getch();
char c;

int main(void)
{ 
	_init_led();
	usart_init(); // initialization of USART 	
	while(1){
		c=usart_getch();
		_blink_led();
		usart_putch(c);
	}
}
void usart_init() {
	UBRRL = BAUD_PRESCALE;
	UBRRH = (BAUD_PRESCALE >> 8); 
	UCSRB = (1<<RXEN)|(1<<TXEN);
	UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
}

unsigned int usart_getch()
{
	while (!(UCSRA & (1 << RXC))); 
	return(UDR); 
}
void usart_putch(char data)
{
   while(!(UCSRA & (1<<UDRE)));
   UDR=data;
}
void _init_led() {
	DDRD |= 1 << PIND7;
}
void _blink_led(){
		PORTD = 1 << PIND7;
		_delay_ms(3);
		PORTD = 0 << PIND7;
		_delay_ms(3);
}

and my Makefile, just part of it :

Code:
MCU = atmega32
F_CPU = 1000000

How it goes ?
Here is the result :
Code:
read: $GPG,12006.1,16.4,201,9,30,800APC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: $GPG,12006.1,16.3,201,8,30,8009PAA,,703113,,21.17APV3,,135,,,573,,,721,,737GS32214324022,
read: 291,320,7PS3,2760,,131,,662,732,8PC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: GG,400,1.8,15.3E27.,.M3,180*F$RC13.0,6.8,16.3,003.,51,D7$PG0.,,,0N0,D0$GPG,13006.1,16.3,2
read: 1,7,30,8000PC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: $GPG,13006.1,16.4,201,7,30,800DPC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: $GPG,13006.1,16.4,201,6,30,8003PC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: $GPG,13006.1,16.4,201,6,30,8000PAA,,703113,,21.17APV3,,135,,,573,,,721,,737GS32214324022,
read: 291,320,7PS3,2760,,131,,662,732,8PC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: GG,450,1.8,15.4E27.,.M3,280*D$RC13.0,6.8,16.4,003.,51,D6$PG0.,,,0N0,D0$GPG,13006.1,16.4,2
read: 1,5,30,8009PC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0
read: $GPG,13006.1,16.4,201,4,30,800EPC03.0A671,,6.2,0032459,D7PT3.4,,.,00,0

Then I try using with Arduino, Here What I got.

Code:
read: $GPVTG,302.14,T,,M,0.00,N,0.0,K,D*0C  
read: 28.000,A,0617.7167,S,10651.4239,E,0.00,302.14,050913,,,D*7F
read: $GPVTG,302.14,T,,M,0.00,N,0.0,K,D*0C
read: $GPGGA,014429.000,0617.7170,S,10651.4241,E,2,05,3.0,65.7,M,3.0,M,2.8,0000*6C
read: $GPGSA,A,3,19,03,23,13,11,,,,,,,,6.4,3.0,5.6*38
read: $GPGSV,3,1,12,11,73,150,21,23,65,278,33,01,48,172,24,19,46,007,33*76
read: $GPGSV,3,2,12,13,40,312,25,20,29,206,16,32,29,173,,03,23,015,19*71
read: $GPGSV,3,3,12,27,16,022,,31,13,120,,06,06,027,,17,03,220,*7B
read: $GPRMC,014429.000,A,0657.1170,S,10751.4241,E,0.00,302.14,050913,,,D*77
read: $GPVTG,302.14,T,,M,0.00,N,0.0,K,D*0C
read: $GPGGA,014430.000,0617.7239,E,2,05,3.1,66.7,M,3.0,M,0.8,0000*62
read: $GPRMC,014430.000,A,0657.1170,S,10751.4241,E,0.00,302.14,050913,,,D*79

The point is :
GPS Holux GR-87 => Arduino ( Success )
GPS Holux GR-87 => Atmega32 or Atmega128 ( Messed Up ).

So, is there something else I should know to make GPS Holux GR-87 can communicate normally with atmega MCU?
 

Enable uart interrupt and in the ISR, store the incoming GPS data in buffer. make a large buffer like >> char buff[100]; , once the buffer is full disable the interrupt and send the buffer data to serial port to check whether its ok or not.

update me.
 

I still looking for the perfect code about this buffering using Interrupt and ISR.
I tried following CodeVisionAVR wizard project, and yes I can see GPRMC and other NMEA stuff, but still some of the returned NMEA is missing and mixed with another sentences.
Code:
read: $GPRMC,005330.000,A,0612.7204,S,10651.4265,E,0.00,,060913,,,A*62
read: $GPV,A,0617.7204,S,10651.4265,E,0.00,,060913,,,A*62   <=== I believe this is part of $GPRMC
read: $GPV,A,0660913,,,A*62TG,,T,,M,0.00,N,0.0,K,A*13
read: $GPGGA,005331.000,0617.7204,S,10651.4265,E,1,11,0.9,53.5,M,3.0,M,287.8,0617.7204,S,10651.  <== This line is mixed up with $GPRMC
read: 265,E,1,11,0.9,53.5,M,3.0,M,287.8,0617.7204,S,10651.4265,E,1,11,0.9,53.5,M,3.0,M,24,179,2
read: ,23,51,317,38,03,43,009,35*70
read: $GPGSV,3,2,12,32,30.9,1.7*3E
read: $GPGSV,3,1,12,19,70,004,43,11,5,2,12,32,30.9,1.7*3E
read: $GPGSV,3,1,12,19,70,004,43,11,5,2,12,32,30.9,1.7*3E
read: $GPGSV,3,1,12,19,70,004,49,35*7D

I am very appreciate If you want to share sample code that works with atmega128 and interrupt ISR for USART.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top