coding error!!help plz

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

coding error!!help plz

Postby yasotha padmanathan » Sun Dec 18, 2011 5:08 pm

i downloaded this source code for LCD frm cytron. but i cldnt run it. it says build failed! can tel me wats d error?
CODE: SELECT_ALL_CODE
//=============================================================================
// Filename: Example_xlcd1.c
//-----------------------------------------------------------------------------
// Compiled using MPLAB-C18 v3.34 student edition
//=============================================================================
// Company   : Cytron Technologies, Malaysia
// Revision   : 1.00
// Date      : 28 Dec 2009
//=============================================================================
#include <p18f4520.h>
#include "xlcd.h"
#include "delays.h"


//=============================================================================
//   Configuration Bits
//=============================================================================
#pragma   config OSC = HS            // HS oscillator
#pragma   config FCMEN = OFF         // Fail-Safe Clock Monitor disabled
#pragma   config IESO = OFF         // Oscillator Switchover mode disabled
#pragma   config PWRT = OFF         // PWRT disabled
#pragma   config BOREN = OFF         // Brown-out Reset disabled in hardware and software
#pragma   config WDT = OFF         // WDT disabled (control is placed on the SWDTEN bit)
#pragma   config MCLRE = ON         // MCLR pin enabled; RE3 input pin disabled
#pragma   config PBADEN = OFF         // PORTB<4:0> pins are configured as digital I/O on Reset
#pragma   config CCP2MX = PORTC      // CCP2 input/output is multiplexed with RC1
#pragma   config LVP = OFF         // Single-Supply ICSP disabled
#pragma   config XINST = OFF         // Extended Instruction Set
//=============================================================================
//   Define Pins
//=============================================================================
#define   led1      LATBbits.LATB6      //active High
#define   led2      LATBbits.LATB7

#define sw1         PORTBbits.RB0
#define sw2         PORTBbits.RB1


//=============================================================================
//   Function Prototypes
//=============================================================================
void Delay_1msX (unsigned int miliseconds);
void Delay_100msX (unsigned int msec);


//=============================================================================
//   Global Variables
//=============================================================================
unsigned int i, t;


//=============================================================================
//   Main Program
//=============================================================================
void main ()
{
   //set I/O input output
   TRISB = 0b00000011;               //Configure PORTB I/O direction
   TRISD = 0b00000000;               //Configure PORTD I/O direction
   PORTB = 0;
   PORTD = 0;

   //-------------------------------------------------------------------------
   // Configure External LCD
     //-------------------------------------------------------------------------
   OpenXLCD( EIGHT_BIT & LINES_5X7 );
   ClearXLCD();                            //Clear display
   
   //-------------------------------------------------------------------------
   // User-defined Graphics
   //-------------------------------------------------------------------------
   SetCGRamAddr(0x40);                     //Goto CGRAM address #1

   // 90 Degree Rotated 'RH'
   putcXLCD(0b11111);
   putcXLCD(0b00100);
   putcXLCD(0b11111);
   putcXLCD(0b00000);
   putcXLCD(0b01001);
   putcXLCD(0b10101);
   putcXLCD(0b10110);
   putcXLCD(0b11111);

   // 90 Degree Rotated '2T'
   putcXLCD(0b10000);
   putcXLCD(0b11111);
   putcXLCD(0b10000);
   putcXLCD(0b00000);
   putcXLCD(0b01001);
   putcXLCD(0b10101);
   putcXLCD(0b10011);
   putcXLCD(0b01001);

   // Battery 1
   putcXLCD(0b01110);
   putcXLCD(0b11011);
   putcXLCD(0b10001);
   putcXLCD(0b10001);
   putcXLCD(0b10001);
   putcXLCD(0b10011);
   putcXLCD(0b10111);
   putcXLCD(0b11111);

   // Battery 2
   putcXLCD(0b01110);
   putcXLCD(0b11011);
   putcXLCD(0b10001);
   putcXLCD(0b10001);
   putcXLCD(0b10011);
   putcXLCD(0b10111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);

   // Battery 3
   putcXLCD(0b01110);
   putcXLCD(0b11011);
   putcXLCD(0b10001);
   putcXLCD(0b10011);
   putcXLCD(0b10111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);

   // Battery 4
   putcXLCD(0b01110);
   putcXLCD(0b11011);
   putcXLCD(0b10011);
   putcXLCD(0b10111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);

   // Battery 5
   putcXLCD(0b01110);
   putcXLCD(0b11011);
   putcXLCD(0b10111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);

   // Battery 6
   putcXLCD(0b01110);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);
   putcXLCD(0b11111);

   ClearXLCD();                            //Clear display
   led1=1;                              //Turn on led1   

   //-------------------------------------------------------------------------
   // Display External LCD
   //-------------------------------------------------------------------------
   SetCurXLCD(0);                        //Set cursor to  line 1, position 0
   putcXLCD(1);                        //Display user-defined graphic 1
   SetCurXLCD(20);                        //Set cursor to  line 2, position 0
   putcXLCD(0);                        //Display user-defined graphic 0

   SetCurXLCD(2);                        //Set cursor to  line 1, position 2
   for(i=2;i<8;i++)                     //Display user-defined graphic 2 to 7
   {
      putcXLCD(i);
   }
   putrsXLCD(" SK40C");                  //Display "SK40C"
   
   while(1)                           //Loop the battery level graphics
   {
      for(i=0;i<6;i++)                  //Refresh battery level graphics
      {                              //continuously every 500ms
         led2=!led2;                     //Toggle led2
         SetCurXLCD(22);                  //Set cursor to line 2, position 2
         putcXLCD(i+2);                  //Display current user-defined graphic
         Delay_100msX(5);               //Delay 500ms
      }
   }   
}//End of main



//=============================================================================
//   Subroutines
//=============================================================================

/********************************************************************
*       Function Name:  Delay_1msX                                  *
*       Return Value:   void                                        *
*       Parameters:     miliseconds: amount of delay            *
*       Description:    This routine generates various delays       *
*                  needed by xlcd functions.               *
*                  For delay of 1ms (18F4550 running at 48MHz)   *
*                  Cycles = (TimeDelay * Fosc) / 4            *
*                  Cycles = (1ms * 48MHz) / 4               *
*                  Cycles = 12,000                        *
*                  Since call of function also takes some       *
*                  instruction cycles, the exact value to get   *
*                  1ms delay is less than 12,000.            *
********************************************************************/
void Delay_1msX (unsigned int miliseconds)
{
   t=0;
   while(t<miliseconds)
   {
      Delay1KTCYx(11);
      Delay10TCYx(96);
      Nop();
      Nop();
      Nop();
      Nop();
      Nop();
      t++;
   }
}//End of Delay_1msX


/********************************************************************
*       Function Name:  Delay_100msX                                  *
*       Return Value:   void                                        *
*       Parameters:     miliseconds: amount of delay            *
*       Description:    This routine generates various delays       *
*                  needed by xlcd functions.               *
*                  For delay of 100ms                     *
*                  (18F4550 running at 48MHz)               *
*                  Cycles = (TimeDelay * Fosc) / 4            *
*                  Cycles = (100ms * 48MHz) / 4            *
*                  Cycles = 1,200,000                     *
*                  Since call of function also takes some       *
*                  instruction cycles, the exact value to get   *
*                  1ms delay is less than 1,200,000.         *
********************************************************************/
void Delay_100msX (unsigned int msec)
{
   t=0;
   while(t<msec)
   {
      Delay10KTCYx(119);
      Delay1KTCYx(9);
      Delay10TCYx(96);
      t++;
   }
}//End of Delay_100msX



the error displayed was :

----------------------------------------------------------------------
Debug build of project `C:\Users\dell\Downloads\SK40C 18F4520 Sample Program\SK40C 18F4520 Sample Program\LCD Display\SK40C_18F4520.mcp' started.
Language tool versions: MPASMWIN.exe v5.30.01, mplink.exe v9.80, mcc18.exe v9.80, mplib.exe v9.80
Preprocessor symbol `__DEBUG' is defined.
Sun Dec 18 17:06:52 2011
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\dell\Downloads\SK40C 18F4520 Sample Program\SK40C 18F4520 Sample Program\LCD Display\SK40C_18F4520.mcs".
Clean: Done.
Executing: "D:\PSM project\mplab\compiler\bin\mcc18.exe" -p=18F4520 "xlcd.c" -fo="xlcd.o" -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
"D:\PSM project\mplab\compiler\bin\picc18" --cmode=c18 -q --asmlist --pass1 -I. --chip=18F4520 xlcd.c -Oxlcd.o -D__DEBUG
xlcd.c: OpenXLCD()
29: Delay_1msX(15);
^ (361) function declared implicit int (warning)
xlcd.c:
115: {
^ (984) type redeclared
^ (1098) conflicting declarations for variable "putrsXLCD" (D:\PSM project\mplab\compiler\include\plib/xlcd.h:129)
^ (252) argument 0 conflicts with prototype
(908) exit status = 1
(908) exit status = 1
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Users\dell\Downloads\SK40C 18F4520 Sample Program\SK40C 18F4520 Sample Program\LCD Display\SK40C_18F4520.mcp' failed.
Language tool versions: MPASMWIN.exe v5.30.01, mplink.exe v9.80, mcc18.exe v9.80, mplib.exe v9.80
Preprocessor symbol `__DEBUG' is defined.
Sun Dec 18 17:06:54 2011
----------------------------------------------------------------------
BUILD FAILED
yasotha padmanathan
Novice
 
Posts: 17
Joined: Sun Oct 16, 2011 10:21 pm

Re: coding error!!help plz

Postby shahrul » Sun Dec 18, 2011 10:46 pm

yasotha padmanathan WROTE:Language tool versions: MPASMWIN.exe v5.30.01, mplink.exe v9.80, mcc18.exe v9.80, mplib.exe v9.80

The code not error, but you not set right compiler. Must use C18 compiler.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: coding error!!help plz

Postby yasotha padmanathan » Mon Dec 19, 2011 4:33 am

but I am using c18 compiler. still build failed!
yasotha padmanathan
Novice
 
Posts: 17
Joined: Sun Oct 16, 2011 10:21 pm

Re: coding error!!help plz

Postby ober » Mon Dec 19, 2011 3:09 pm

Would you mind print screen the project window for us?
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: coding error!!help plz

Postby yasotha padmanathan » Wed Dec 21, 2011 10:40 pm

what do you mean by project window...? which 1 i should print screen?
yasotha padmanathan
Novice
 
Posts: 17
Joined: Sun Oct 16, 2011 10:21 pm

Re: coding error!!help plz

Postby robosang » Thu Dec 22, 2011 10:57 pm

I think Ober refer to left top corner of MPLAB IDE, where there is a small window showing all your c files under Source File folder and header files.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: coding error!!help plz

Postby yasotha padmanathan » Fri Dec 23, 2011 11:08 am

This is my project window
Attachments
Untitled.png
yasotha padmanathan
Novice
 
Posts: 17
Joined: Sun Oct 16, 2011 10:21 pm

Re: coding error!!help plz

Postby ober » Sat Dec 24, 2011 1:18 pm

is there any xlcd.c file beside xlcd.h in the project folder? It seem you did not include the xlcd.c under Source Files folder in your project window.

Also check if there is any delays.c file, if there is, please include it under Source Files folder too. Try it again, might solve the problem, but not necessary that is the only problem 8-)
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest

cron