Code for testing EM-406A GPS with atmega8

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just wanted to test my EM-406A GPS module,by,-

1. Connecting GPS's TX to Atmega8's RX via a 2.8V to 5V level converter

2. Connecting MCU's TX to my PC via standard MAX-232 IC and the serial port

3. I haven't connected my GPS's RX to anything as at present I don't want to send any commands to it.

I wrote a simple code to see what my module was spitting out--


#include
#include
#include "usart.c"

void init()
{
       USART_init(155);//BAUD corresponding to Baud Rate 4800

       UCSRB |= (1 << RXCIE); // Enable the USART Recieve Complete interrupt (USART_RXC) 

       sei();// Enable the Global Interrupt Enable flag so that interrupts can be processed 
 }

ISR(USART_RXC_vect) 
{ 
	char c; 
	
        c = UDR; // Fetch the recieved byte value into the variable "ByteReceived" 
	
        UDR=c;
	 // Echo back the received byte back to the computer 
}


void main()
{
	init();
	while(1)
	{
        //Interrupts will do the job
	  }

 }

But I didn't see any data on my terminal. It's probably a hardware problem, but just wanted to know if there could be anything wrong with the code?.

Also ,does the module work indoors,mine isnt getting a fix(LED not flashing) inside my house. Lot of trees and wires near my window.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where does your 155 number come from? The comment says "4800" - if I look at the tables in the datasheet you have:

FCPU=8Mhz, UBRR=103
FCPU=11.0592MHz, UBRR=143
FCPU=14.7456MHz, UBRR=191

This seems to suggest your FCPU is somewhere between 11.0592 and 14.7456. Could it be that you are using a 12MHz crystal as 12000000/(4800 * 16) - 1 = 155.25

If that's the case exactly how sure are you that you have fused the AVR so it really is clocking at 12MHz? What have you done to verify this?

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry i forgot to mention indeed my clock is 12Mhz,I am working on a kit and have previously also used 12Mhz to achieve accurate Timer delays and in PWM. So,I am pretty sure that's not the case.

I am measuring the voltage on my module's TX pin and it's equal to 0 volt,even though it's LED is on ,it's not spitting any data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read somewhere I should keep the RX pin on GPS high if not used,I am not doing that presently,could that affect my GPS data,so much so that TX is showing 0 volts.