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.

Problem with MPLAB with CCS Compiler code

Status
Not open for further replies.
Hi bmb_10 thank you, yes I wanted because of the Schematic that's all, also another question I have LCD and I have connected everything, when I connect pickit2 I can see one line with block box but nothing is displaying, so I don't what I have done wrong,

LCD
PIN 1 --> Ground
PIN 2 --> +5V
PIN 3 --> POT 10K
PIN 4 - RS --> RD1
PIN 5 - R/W --> RD2
PIN 6 - E --> RD0
PIN 7 --> didn't connect
PIN 8 --> didn't connect
PIN 9 -->didn't connect
PIN 10 --> didn't connect
PIN 11 --> RD4
PIN 12 --> RD5
PIN 13 --> RD6
PIN 14 --> RD7
PIN 15 --> didn't connect
PIN 16 --> didn't connect

This is the code

Code:
#include <16F877A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //Crystal osc <= 20mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

#define LCD_DB4 PIN_D4 
#define LCD_DB5 PIN_D5 
#define LCD_DB6 PIN_D6 
#define LCD_DB7 PIN_D7 

#define LCD_E PIN_D0 
#define LCD_RS PIN_D1 
#define LCD_RW PIN_D2 


void main(void) 
{ 

lcd_init(); 
delay_ms(5);   
lcd_putc("\f"); //Clear display 
delay_ms(5); 
lcd_gotoxy(1,1); 
delay_ms(5); 
lcd_putc("Champ");  // you want to send this to the lcd only once 

while(TRUE) 
{ 

// LCD Display // 

delay_ms(1000); 
} 

}

Anything wrong with that code??Also am using MPLAB with pickit to run this code......
 

Hello papizo, please look at the line that I have included within the code: #include <lcd.c>. This line must always be after declaring the pin assignment. Which version of CCS you have?

Code:
#include <16F877A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //Crystal osc <= 20mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

#define LCD_DB4 PIN_D4 
#define LCD_DB5 PIN_D5 
#define LCD_DB6 PIN_D6 
#define LCD_DB7 PIN_D7 

#define LCD_E PIN_D0 
#define LCD_RS PIN_D1 
#define LCD_RW PIN_D2

#include <lcd.c>                 // Must always be after declaring the pin assignment...


void main(void) 
{
   lcd_init(); 
   delay_ms(5);   
   lcd_putc("\f"); //Clear display 
   delay_ms(5); 
   lcd_gotoxy(1,1); 
   delay_ms(5); 
   lcd_putc("Champ");  // you want to send this to the lcd only once 

   while(TRUE) 
   {
      // LCD Display // 
      delay_ms(1000); 
   } 
}

Greetings!
 
  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating
It seems that you are connecting your LCD in 4 bit mode. As bmb_10 has mentioned, you have to include the lcd.c file. So the LCD initializes. It makes you to do less work. But you don't know whats happening inside. If you want to learn and to gain deep knowledge, try to do without using lcd.c file. And i recommend you to do in 8 bit mode. If you successfully did in 8 bit mode, try to implement the ideas and do it in 4 bit mode. If you are stuck up, Please feel free to ask anything. i can help you.
 
  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating
Hi I have tried both ways but not is display so I don't know what to do now, I have tried to connect pin RW to ground still the same problem any idea what I should do? I lok the code in my drivers for LCD.c which is

Code:
//////////////////////////////////////////////////////////////////////////////
////                             LCD.C                                     ////
////                 Driver for common LCD modules                         ////
////                                                                       ////
////  lcd_init()   Must be called before any other function.               ////
////                                                                       ////
////  lcd_putc(c)  Will display c on the next position of the LCD.         ////
////                     The following have special meaning:               ////
////                      \f  Clear display                                ////
////                      \n  Go to start of second line                   ////
////                      \b  Move back one position                       ////
////                                                                       ////
////  lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)        ////
////                                                                       ////
////  lcd_getc(x,y)   Returns character at position x,y on LCD             ////
////                                                                       ////
////  CONFIGURATION                                                        ////
////  The LCD can be configured in one of two ways: a.) port access or     ////
////  b.) pin access.  Port access requires the entire 7 bit interface     ////
////  connected to one GPIO port, and the data bits (D4:D7 of the LCD)     ////
////  connected to sequential pins on the GPIO.  Pin access                ////
////  has no requirements, all 7 bits of the control interface can         ////
////  can be connected to any GPIO using several ports.                    ////
////                                                                       ////
////  To use port access, #define LCD_DATA_PORT to the SFR location of     ////
////  of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP    ////
////  of this file to configure the pin order.  If you are using a         ////
////  baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must  ////
////  be defined.                                                          ////
////                                                                       ////
////  Example of port access:                                              ////
////     #define LCD_DATA_PORT getenv("SFR:PORTD")                         ////
////                                                                       ////
////  To use pin access, the following pins must be defined:               ////
////     LCD_ENABLE_PIN                                                    ////
////     LCD_RS_PIN                                                        ////
////     LCD_RW_PIN                                                        ////
////     LCD_DATA4                                                         ////
////     LCD_DATA5                                                         ////
////     LCD_DATA6                                                         ////
////     LCD_DATA7                                                         ////
////                                                                       ////
////  Example of pin access:                                               ////
////     #define LCD_ENABLE_PIN  PIN_E0                                    ////
////     #define LCD_RS_PIN      PIN_E1                                    ////
////     #define LCD_RW_PIN      PIN_E2                                    ////
////     #define LCD_DATA4       PIN_D4                                    ////
////     #define LCD_DATA5       PIN_D5                                    ////
////     #define LCD_DATA6       PIN_D6                                    ////
////     #define LCD_DATA7       PIN_D7                                    ////
////                                                                       ////
///////////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2009 Custom Computer Services           ////
//// This source code may only be used by licensed users of the CCS C  ////
//// compiler.  This source code may only be distributed to other      ////
//// licensed users of the CCS C compiler.  No other use, reproduction ////
//// or distribution is permitted without written permission.          ////
//// Derivative programs created using this software in object code    ////
//// form are not restricted in any way.                               ////
///////////////////////////////////////////////////////////////////////////

typedef struct  
{                            // This structure is overlayed
   BOOLEAN enable;           // on to an I/O port to gain
   BOOLEAN rs;               // access to the LCD pins.
   BOOLEAN rw;               // The bits are allocated from
   BOOLEAN unused;           // low order up.  ENABLE will
   int     data : 4;         // be LSB pin of that port.
  #if defined(__PCD__)       // The port used will be LCD_DATA_PORT.
   int    reserved: 8;
  #endif
} LCD_PIN_MAP;

#if defined(__PCB__)
   // these definitions only need to be modified for baseline PICs.
   // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
/*                                    EN, RS,   RW,   UNUSED,  DATA  */
 const LCD_PIN_MAP LCD_OUTPUT_MAP =  {0,  0,    0,    0,       0};
 const LCD_PIN_MAP LCD_INPUT_MAP =   {0,  0,    0,    0,       0xF};
#endif

////////////////////// END CONFIGURATION ///////////////////////////////////

#ifndef LCD_ENABLE_PIN
   #define lcd_output_enable(x) lcdlat.enable=x
   #define lcd_enable_tris()   lcdtris.enable=0
#else
   #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
   #define lcd_enable_tris()  output_drive(LCD_ENABLE_PIN)
#endif

#ifndef LCD_RS_PIN
   #define lcd_output_rs(x) lcdlat.rs=x
   #define lcd_rs_tris()   lcdtris.rs=0
#else
   #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
   #define lcd_rs_tris()  output_drive(LCD_RS_PIN)
#endif

#ifndef LCD_RW_PIN
   #define lcd_output_rw(x) lcdlat.rw=x
   #define lcd_rw_tris()   lcdtris.rw=0
#else
   #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
   #define lcd_rw_tris()  output_drive(LCD_RW_PIN)
#endif

#ifndef LCD_DATA_PORT
   #if defined(__PCB__)
      #define LCD_DATA_PORT      0x06     //portb
      #define set_tris_lcd(x)   set_tris_b(x)
   #elif defined(__PCM__)
      #define LCD_DATA_PORT      getenv("SFR:PORTD")     //portd
   #elif defined(__PCH__)
      #define LCD_DATA_PORT      getenv("SFR:PORTD")    //portd
   #elif defined(__PCD__)
      #define LCD_DATA_PORT      getenv("SFR:PORTD")    //portd
   #endif   
#endif

#if defined(__PCB__)
   LCD_PIN_MAP lcd, lcdlat;
   #byte lcd = LCD_DATA_PORT
   #byte lcdlat = LCD_DATA_PORT
#elif defined(__PCM__)
   LCD_PIN_MAP lcd, lcdlat, lcdtris;
   #byte lcd = LCD_DATA_PORT
   #byte lcdlat = LCD_DATA_PORT
   #byte lcdtris = LCD_DATA_PORT+0x80
#elif defined(__PCH__)
   LCD_PIN_MAP lcd, lcdlat, lcdtris;
   #byte lcd = LCD_DATA_PORT
   #byte lcdlat = LCD_DATA_PORT+9
   #byte lcdtris = LCD_DATA_PORT+0x12
#elif defined(__PCD__)
   LCD_PIN_MAP lcd, lcdlat, lcdtris;
   #word lcd = LCD_DATA_PORT
   #word lcdlat = LCD_DATA_PORT+2
   #word lcdtris = LCD_DATA_PORT-0x02
#endif

#ifndef LCD_TYPE
   #define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines
#endif

#ifndef LCD_LINE_TWO
   #define LCD_LINE_TWO 0x40    // LCD RAM address for the second line
#endif

BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
                             // These bytes need to be sent to the LCD
                             // to start it up.

// original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
// LCD_DATA1 as LCD_DATA5, and so on.  this block of code makes the driver
// compatible with any code written for the original library
#if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
   #define  LCD_DATA4    LCD_DATA0
   #define  LCD_DATA5    LCD_DATA1
   #define  LCD_DATA6    LCD_DATA2
   #define  LCD_DATA7    LCD_DATA3
#endif

BYTE lcd_read_nibble(void);

BYTE lcd_read_byte(void)
{
   BYTE low,high;

 #if defined(__PCB__)
   set_tris_lcd(LCD_INPUT_MAP);
 #else
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   output_float(LCD_DATA4);
   output_float(LCD_DATA5);
   output_float(LCD_DATA6);
   output_float(LCD_DATA7);
  #else
   lcdtris.data = 0xF;
  #endif
 #endif
        
   lcd_output_rw(1);
   delay_cycles(1);
   lcd_output_enable(1);
   delay_cycles(1);
   high = lcd_read_nibble();
      
   lcd_output_enable(0);
   delay_cycles(1);
   lcd_output_enable(1);
   delay_us(1);
   low = lcd_read_nibble();
      
   lcd_output_enable(0);

 #if defined(__PCB__)
   set_tris_lcd(LCD_INPUT_MAP);
 #else
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   output_drive(LCD_DATA4);
   output_drive(LCD_DATA5);
   output_drive(LCD_DATA6);
   output_drive(LCD_DATA7);
  #else
   lcdtris.data = 0x0;
  #endif
 #endif

   return( (high<<4) | low);
}

BYTE lcd_read_nibble(void)
{
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   BYTE n = 0x00;

   /* Read the data port */
   n |= input(LCD_DATA4);
   n |= input(LCD_DATA5) << 1;
   n |= input(LCD_DATA6) << 2;
   n |= input(LCD_DATA7) << 3;
   
   return(n);
  #else
   return(lcd.data);
  #endif
}

void lcd_send_nibble(BYTE n)
{
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   /* Write to the data port */
   output_bit(LCD_DATA4, BIT_TEST(n, 0));
   output_bit(LCD_DATA5, BIT_TEST(n, 1));
   output_bit(LCD_DATA6, BIT_TEST(n, 2));
   output_bit(LCD_DATA7, BIT_TEST(n, 3));
  #else      
   lcdlat.data = n;
  #endif
      
   delay_cycles(1);
   lcd_output_enable(1);
   delay_us(2);
   lcd_output_enable(0);
}

void lcd_send_byte(BYTE address, BYTE n)
{
   lcd_output_rs(0);
   while ( bit_test(lcd_read_byte(),7) ) ;
   lcd_output_rs(address);
   delay_cycles(1);
   lcd_output_rw(0);
   delay_cycles(1);
   lcd_output_enable(0);
   lcd_send_nibble(n >> 4);
   lcd_send_nibble(n & 0xf);
}

void lcd_init(void) 
{
   BYTE i;

 #if defined(__PCB__)
   set_tris_lcd(LCD_OUTPUT_MAP);
 #else
  #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
   output_drive(LCD_DATA4);
   output_drive(LCD_DATA5);
   output_drive(LCD_DATA6);
   output_drive(LCD_DATA7);
  #else
   lcdtris.data = 0x0;
  #endif
   lcd_enable_tris();
   lcd_rs_tris();
   lcd_rw_tris();
 #endif

   lcd_output_rs(0);
   lcd_output_rw(0);
   lcd_output_enable(0);
    
   delay_ms(15);
   for(i=1;i<=3;++i)
   {
       lcd_send_nibble(3);
       delay_ms(5);
   }
    
   lcd_send_nibble(2);
   for(i=0;i<=3;++i)
      lcd_send_byte(0,LCD_INIT_STRING[i]);
}

void lcd_gotoxy(BYTE x, BYTE y)
{
   BYTE address;

   if(y!=1)
      address=LCD_LINE_TWO;
   else
      address=0;
     
   address+=x-1;
   lcd_send_byte(0,0x80|address);
}

void lcd_putc(char c)
{
   switch (c)
   {
      case '\f'   :  lcd_send_byte(0,1);
                     delay_ms(2);
                     break;
                     
      case '\n'   : lcd_gotoxy(1,2);        break;
     
      case '\b'   : lcd_send_byte(0,0x10);  break;
     
      default     : lcd_send_byte(1,c);     break;
   }
}
 
char lcd_getc(BYTE x, BYTE y)
{
   char value;

   lcd_gotoxy(x,y);
   while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
   lcd_output_rs(1);
   value = lcd_read_byte();
   lcd_output_rs(0);
   
   return(value);
}

What about my delays I don't have to change and what about that LCD.c code???Any help I will appreciate...
 

okey.. Now i'll explain how to interface LCD in 8 bit mode without using those lcd.c ...lcd.c is a file, someone has created for
us to do less work. I don't want another man to do my work.
Try this code. It will work. But know every step what you do. R/W pin is connected to ground. I have connected port B to Data pins of LCD. if you want to change the portb to PORTD, you can see the line output_b(), change it as output_d()...
HTML:
#include "16F877a.h"
#fuses HS				
#use delay(clock=20000000) 	 // 20MHz

void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);

#define RS PIN_A2   // LCD RS pin connected to uC A2
#define EN PIN_A1	// LCD EN pin connected to uC A1

void main()
{
set_tris_b(0x00);
lcd_init();
lcd_data("Hellow");
}
//////// LCD initialization///////////
void lcd_init()
{
lcd_cmd(0x30);  // Configure the LCD in 8-bit mode, 1 line and 5x7 font
lcd_cmd(0x0c);  // Display On and Cursor Off
lcd_cmd(0x01);  // Clear display screen
lcd_cmd(0x06);  // Increment cursor
lcd_cmd(0x80);  // Set cursor position to 1st line, 1st column
}
// command mode .. RS must be low. EN goes high to low
void lcd_cmd(unsigned char z)
{
output_b(z);
output_low(RS);   
output_high(EN);
delay_ms(15);
output_low(EN);
}
// data mode .. RS must be high .. EN goes high to low .. 
void lcd_data(unsigned char c)
{
output_b(c);
output_high(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
 
  • Like
Reactions: bmb_10 and Papizo

    V

    Points: 2
    Helpful Answer Positive Rating

    Papizo

    Points: 2
    Helpful Answer Positive Rating

    bmb_10

    Points: 2
    Helpful Answer Positive Rating
Hello papizo, before all, I would like to ask you again what version of CCS C you have?

Greetings!

PD. In addition, can you upload the circuit schematic you are using?
 
Last edited:
  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating
Hi papizo, as I had some free time, I just test the code and it works perfectly. Also tested the code posted by hemnath and also works very well. However, I prefer to use the LCD in 4-bit mode, because you're saving 4-pin of the microcontroller. On the other hand the lcd.c library that has been developed by CCS, has implemented various features such as for example:

Code:
////  lcd_putc(c)  Will display c on the next position of the LCD.         ////
////                     The following have special meaning:               ////
////                      \f  Clear display                                ////
////                      \n  Go to start of second line                   ////
////                      \b  Move back one position                       ////
////                                                                       ////
////  lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)        ////
////                                                                       ////
////  lcd_getc(x,y)   Returns character at position x,y on LCD             ////

This does not mean that you can not add to hemnath's code, these and more features yet, but I think that one of the main advantages of the CCS compiler, especially if you're a beginner, is that you can develop codes quickly without worrying about doing each library that you need (CCS offers you many libraries ready to use) or declaring every register as you have to do with other compilers. Well, after all this, I must clarify that I do not work for CCS :lol: (don't forget tell us which CCS version you have)

Greetings!
 
  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating
okey.. Now i'll explain how to interface LCD in 8 bit mode without using those lcd.c ...lcd.c is a file, someone has created for
us to do less work. I don't want another man to do my work.
Try this code. It will work. But know every step what you do. R/W pin is connected to ground. I have connected port B to Data pins of LCD. if you want to change the portb to PORTD, you can see the line output_b(), change it as output_d()...
HTML:
#include "16F877a.h"
#fuses HS				
#use delay(clock=20000000) 	 // 20MHz

void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);

#define RS PIN_A2   // LCD RS pin connected to uC A2
#define EN PIN_A1	// LCD EN pin connected to uC A1

void main()
{
set_tris_b(0x00);
lcd_init();
lcd_data("Hellow");
}
//////// LCD initialization///////////
void lcd_init()
{
lcd_cmd(0x30);  // Configure the LCD in 8-bit mode, 1 line and 5x7 font
lcd_cmd(0x0c);  // Display On and Cursor Off
lcd_cmd(0x01);  // Clear display screen
lcd_cmd(0x06);  // Increment cursor
lcd_cmd(0x80);  // Set cursor position to 1st line, 1st column
}
// command mode .. RS must be low. EN goes high to low
void lcd_cmd(unsigned char z)
{
output_b(z);
output_low(RS);   
output_high(EN);
delay_ms(15);
output_low(EN);
}
// data mode .. RS must be high .. EN goes high to low .. 
void lcd_data(unsigned char c)
{
output_b(c);
output_high(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}

Thank you a lot, I had problem with my LCD display spend 2 days changing your code and bmb_10 code playing around to find out what is the problem and why is not working and yesterday I found my LCD display it was not working, so thank you a lot and I have change back to 4 bit mode and 8 bit worked fine.

- - - Updated - - -

Hi bmb_10,

Am using CCS C compiler version 4 and also the LCD is working fine now fine without any problem..... Had problem with my LCD display and I changed and got new one and both of your codes works perfect.

Thank you a lot..
 

Hi guys am back,I had to change my PIC16 to PIC18 which have two serial port, one port I will use for gsm and another one for gps, but problem I have now, I have tested my gps with PC and everything worked fine, so far what I want is to display the latitude and longitude on the LCD but am not too sure how to write the code any idea or simple code I will appreciate...

- - - Updated - - -

Code:
Program to Interface GPS with PIC18F4550 Microcontroller
#define FREQ 12000000
#define baud 4800
#define spbrg_value (((FREQ/64)/baud)-1)
#define rs LATA.F0
#define rw LATA.F1
#define en LATA.F2
#define lcdport LATB
unsigned char rx_data();
void lcd_ini();
void lcdcmd(unsigned char);
void lcddata(unsigned char);

unsigned char longi_data[12];
unsigned char lati_data[12];
unsigned char data,value=0;
unsigned int i=0,pos;

void main()
{
	TRISB=0;			// Set Port B as output port
	LATB=0;
	TRISA=0;
	LATA=0;
	SPBRG=spbrg_value;		// Fill SPBRG register to set the baud rate
	RCSTA.SPEN=1;			// To activate serial port (Tx and Rx pins)                                    
	RCSTA.CREN=1;			// To enable continuous reception
	lcd_ini();
	while(1)
	{
		data=rx_data();                     // Check the string '$GPGGA,'
		if(data=='$')
		{
			data=rx_data();
			if(data=='G')
			{
				data=rx_data();
				if(data=='P');
				{
					data=rx_data();
					if(data=='G');
					{
						data=rx_data();
						if(data=='G')
						{
						data=rx_data();
						if(data=='A')
						{
						data=rx_data();
						if(data==',')
						{
						data=rx_data();
						while(data!=',')
						data=rx_data();
						for(i=0;data!='N';i++)
						data=rx_data();
						lati_data[i]=data;  // Store the Latitude data
						}
						data=rx_data();
						if(data==',')
						{
						for(i=0;data!='E';i++)
						{
						data=rx_data();
						longi_data[i]=data;  // Store the Longitude data
						}
						}
						i=0;
						lcdcmd(0x80);
						while(i<11)
						{
						lcddata(lati_data[i]);	// Print the Latitude data
						i++;
						}
						i=0;
						lcdcmd(0xC0);
						while(i<12)
						{
						lcddata(longi_data[i]);	  // Print the Longitude data
						i++;
						}
						}
						}
						}
					}
				}
			}
		}
		Delay_ms(1000);
		for(i=0;i<12;i++)
		{
			data=0;
			lati_data[i]=0;
			longi_data[i]=0;
		}
	}
}

unsigned char rx_data(void)
{
	while(PIR1.RCIF==0);		// Wait until RCIF gets low
	return RCREG;			// Store data in Reception register
}

void lcd_ini()
{
	lcdcmd(0x38);		// Configure the LCD in 8-bit mode, 2 line and 5x7 font
	lcdcmd(0x0C);		// Display On and Cursor Off
	lcdcmd(0x01);		// Clear display screen
	lcdcmd(0x06);		// Increment cursor
	lcdcmd(0x80);		// Set cursor position to 1st line, 1st column
}

void lcdcmd(unsigned char cmdout)
{
	lcdport=cmdout;		//Send command to lcdport=PORTB
	rs=0;						
	rw=0;
	en=1;
	Delay_ms(10);
	en=0;
}

void lcddata(unsigned char dataout)
{
	lcdport=dataout;	//Send data to lcdport=PORTB
	rs=1;
	rw=0;
	en=1;
	Delay_ms(10);
	en=0;
}

Any chance to modify this code so I can use in CCS C compiler please. because this code works with C and not with CCS C compiler
 

  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating

Hi papizo, which microcontroller are you using and what model is your GPS module?

Greetings!
 
  • Like
Reactions: Papizo

    Papizo

    Points: 2
    Helpful Answer Positive Rating
Hi papizo, which microcontroller are you using and what model is your GPS module?

Greetings!

Thank you for your reply hopeful I will get more advice and support
 

Hi Papizo, sorry for the delay in responding, but i have had a lot of work these days. I was looking at the datasheet of the GPS 9540 module and now I have to ask yourself: How is going the study of the CCS book? Have you get the chapter for communication modules? It seems (I have never worked with a GPS module) that with this GPS module is easy to establish a communication with a PIC, but you must be very clear and studied first and foremost the part of the USART module for you develop! The PIC18F46k22 you will use, has a EUSART (Enhanced Universal Synchronous Asynchronous Receiver Transmitter) module. You must study this chapter also in the datasheet of that PIC (page 267).

Greetings!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top