Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

gps with pic 18f4520

Home Forums MPLAB XC8 Tutorial Discussions gps with pic 18f4520

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  Bitahwa Bindu 1 year, 8 months ago.

  • Author
  • #2575


    hello again ! this is a testing code , i juste try to get charcter from gps receiver via usart

    with PICDEM 2 PLUS:

    #define _XTAL_FREQ 8000000

    #define RS RD4
    #define EN RD6
    #define D4 RD0
    #define D5 RD1
    #define D6 RD2
    #define D7 RD3
    #include <stdio.h>
    #include <xc.h>
    #include <plib/usart.h>
    #include “lcd.h”

    #pragma config OSC = HS // Oscillator Selection bits (HS oscillator)
    #pragma config WDT = OFF // Watchdog Timer Enable bit (WDT enabled)
    #pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
    #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
    #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
    #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
    #pragma config WRT0 = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
    #pragma config CP0 = OFF // Flash Program Memory Code Protection bit (Code protection off)

    void interrupt ISR(){
    unsigned char c;
    if (DataRdyUSART())

    int a=1;
    char s;
    int main()

    TRISD = 0x00;
    TRISC7 = 0; //PORTB as Output


    s = getcUSART();

    return 0;

  • #2576


    you find my mplab prject zipped

  • #2578

    Bitahwa Bindu

    They must be some incompatibility of peripheral libraries with XC8 v1.41. That is why it’s giving that error. We tried your code with XC8 v1.34 it compiles well without any problem. As you are aware microchip is phasing out the peripheral libraries, they want people to use the new MPLAB Code Configurator, they are no longer updating the peripheral libraries and thus might not be compatible with new compilers. We would advice you to download XC8 v1.34 under the: Download archives


  • #2646


    hello again , i really need help please!!!

    i try to read gps data (NMEA) form GPS receiver (EM-506) i use pic18f4520 suporrted on PICDEM 2 PLUS board. (i use Mplab x and XC8 as compiler)

    my problem is that i can’t read data via USART . thanks for help

    • #2648

      Bitahwa Bindu

      Hi. You are not specific with your problem. We have many USART tutorials on our website. What do you mean you can’t read?

      How are you reading? and What kind of data? Are you simulating or on hardware? are you sure your hardware is working correctly?


You must be logged in to reply to this topic.

Select your currency
EUR Euro
USD United States (US) dollar