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 3 months, 3 weeks ago.

  • Author
    Posts
  • #2575

    Anonymous

    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”

    // BEGIN CONFIG
    #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)
    //END CONFIG

    void interrupt ISR(){
    unsigned char c;
    if (DataRdyUSART())
    {
    c=getcUSART();
    Lcd_Write_Char(c);
    }

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

    TRISD = 0x00;
    Lcd_Init();
    TRISC7 = 0; //PORTB as Output
    OpenUSART(USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX &USART_BRGH_HIGH & USART_ADDEN_OFF,52);

    do
    {
    if(DataRdyUSART())
    {

    s = getcUSART();
    __delay_ms(3000);
    Lcd_Write_Char(s);
    }
    }while(1);

    return 0;
    }

  • #2576

    Anonymous

    you find my mplab prject zipped

  • #2578

    Bitahwa Bindu
    Keymaster

    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

     

    • This reply was modified 3 months, 3 weeks ago by  Bitahwa Bindu.
  • #2646

    Anonymous

    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
      Keymaster

      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.