Mplab help!!!

Thread Starter

Rk17

Joined Apr 23, 2011
43
helo its my first time to post here i really need some help regarding mplab. i cant compile a code in mplab ide; i use the hi-tech compiler; here is the code

#include <16c84.h> #USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */ #FUSES XT,NOWDT,NOPROTECT,NOPUT /* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */ #byte port_b=6 /* define the location of register port_b */ main(){ byte cnt; value; set_tris_b(0); /* set port_b to be outputs */ port_b = 0; /* initialize All port_b outp/uts to be zero */ value = 0x01; while( TRUE ) { /* forever loop using WHILE construct */ cnt = 0; while ( cnt<8 ) { port_b = value; DELAY_MS(1000); value = value << 1; /* shift left will put 0x01, 0x02, 0x04, 0x08, 0x10 */ cnt++; /* 0x20, 0x40, 0x80 to port_b */ } } }

>>and here is the error;

Build C:\Documents and Settings\Administrator\My Documents\forsundayfinal\srv for device 16F84A
Using driver C:\Program Files\HI-TECH Software\PICC\9.81\bin\picc.exe

Make: The target "C:\Documents and Settings\Administrator\My Documents\forsundayfinal\srv.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC\9.81\bin\picc.exe" --pass1 "C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\srv.c" -q --chip=16F84A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [141] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\srv.c; 1.18 can't open include file "16c84.h": No such file or directory

********** Build failed! **********


**i dont know the cause of this.. please help me.. tnx in advnce!


 

nerdegutta

Joined Dec 15, 2009
2,684
For starters, if you edit your post, and use the code - tag, the readability will be much better. :)

What PIC are you programming? 16F84 or 16C84?

Try changing the:
Rich (BB code):
#include <16c84.h>
with:
Rich (BB code):
#include <htc.h>
You configuration word looks also a bit off...
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
im kind of a rookie in this stuff but thanks for the help bor i really appreciate it by the way what does #include <htc.h> mean?

ive did what you said and the result got better but still faild to compile here is the error code i got>>

Make: The target "C:\Documents and Settings\Administrator\My Documents\forsundayfinal\srv.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC\9.81\bin\picc.exe" --pass1 "C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c" -q --chip=16F84A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Warning [361] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 54.1 function declared implicit int
Warning [361] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 56.1 function declared implicit int
Warning [361] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 58.1 function declared implicit int
Executing: "C:\Program Files\HI-TECH Software\PICC\9.81\bin\picc.exe" -osrv.cof -msrv.map --summary=default --output=default srv.p1 --chip=16F84A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C Compiler for PIC10/12/16 MCUs (PRO Mode) V9.81
Copyright (C) 2010 Microchip Technology Inc.
Licensed for evaluation purposes only.
This licence will expire on Tue, 07 Jun 2011.
Warning [1090] C:\Documents and Settings\Administrator\My Documents\pic16F84 projects\16F84A_delay (100)\srv.c; 41. variable "_i" is not used
Error [500] ; 0. undefined symbols:
_Delay_ms(srv.obj) _resBit(srv.obj) _setBit(srv.obj)

********** Build failed! **********

ive program the source code on my PIC16F84A and it worked when i used the hex file that was the 100ms delay time.
I wish to recompile the file to do a little experiment (change 100ms to 5000ms) but it turned out to be that mplab cant recompile

further help would be highly appreciated tnx in advance
 

spinnaker

Joined Oct 29, 2009
7,830
Repost your code with code tags as suggested and mark whicj line is 361.

but those are warnings and usually nothing to worry about.

This line

Error [500] ; 0. undefined symbols:
_Delay_ms(srv.obj) _resBit(srv.obj) _setBit(srv.obj)

is an error and it means these are functions missing from your project. The need to be included either from a library or source code included in your project.

And this should have been posted in the embedded forum and not here. Hopefully a mod will move it soon. If not then PM a mode.
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
sir it seems that _Delay_ms(srv.obj) _resBit(srv.obj) _setBit(srv.obj) are terms which mplab can not indentify. here is the code
>>
#include <htc.h>

void main() {
unsigned short pa=0;
unsigned int i;


PORTA = 0;
TRISA = 0; // o/p - sets analogue pins to digital output

TRISB = 0;
PORTB = 0;

while(1) {

pa=~pa;
if (pa) {
setBit(PORTB,3);
} else {
resBit(PORTB,3);
}
Delay_ms(100);
} ; // infinite while loop
}

>>i got this from this link http://www.best-microcontroller-projects.com/pic16f84.html#Circuit_diagram

im using mplab.. but it says mikroC is there a difference between the two? they have the same commands in c right?

i have a .ppc file also downloaded with it but i dont know how to open it.

tnx for the help sir
 

nerdegutta

Joined Dec 15, 2009
2,684
This line:
Rich (BB code):
#include <htc.h>
tells the compiler to include the file htc.h at compile time.

Try:
Rich (BB code):
__delay_ms(1000);
Instead of:
Rich (BB code):
Delay_ms(1000);
You can not mix MikroC and MPLAB Hi-tech C. Stick with one of them.
 

t06afre

Joined May 11, 2009
5,934
You are using a program not written for HI-Tech C hence all your problems.
before you do anything more I will STRONGLY recommend reading the document
C:\Program Files\HI-TECH Software\PICC\9.81\docs\quickstart.pdf
Then in the same folder you will also find the manual. Check out the function __delay_ms. And HI-tech C also do not use the
Rich (BB code):
#FUSES XT,NOWDT,NOPROTECT,NOPUT
but rather
Rich (BB code):
__CONFIG(XT & WDTDIS & PWRTDIS & BORDIS & LVPEN & WRTEN &DEBUGEN & DUNPROT & UNPROTECT);
as an example. This setting may not apply to your MCU
And please use code tags
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
i still got this error message:

Rich (BB code):
Error   [500] ; . undefined symbols:
    _resBit (16F84_LED_Flash.obj)_setBit (16F84_LED_Flash.obj)___delay_ms (16F84_LED_Flash.obj)
it says undefined symbols is my code still wrong?
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
Rich (BB code):
 //////////////////////////////////////////////////////////////////////
//
// File: 16F84_led_flash.c
//
// Author: J F Main.
//
// Description:
//
//   Flash an led at RB3
//
// Compiler : mikroC, mikroElektronika C compiler
//            for Microchip PIC microcontrollers
//            Version: 5.0.0.3
//
// Note Testing:
//
//   Tested on 16F84
//
// Requirements:
//
//   Target : 16F84
//
// Notes :
//
//   Uses internal oscillator.
//
// Version:
// 1.00 Initial release.
//
// Copyright : Copyright © John Main 2006
//   http://www.best-microcontroller-projects.com
//   Free for non commercial use as long as this entire copyright notice
//   is included in source code and any other documentation.
//
//////////////////////////////////////////////////////////////////////

#include <htc.h>

void main() {
unsigned short pa=0;
unsigned int i;


  PORTA = 0;
  TRISA = 0; // o/p   - sets analogue pins to digital output

  TRISB = 0;
  PORTB = 0;

  while(1) {

     pa=~pa;
     if (pa) {
        setBit(PORTB,3);
     } else {
        resBit(PORTB,3);
     }
     Delay_ms(100);
  } ; // infinite while loop
}
this is the link where i got the code

[LINK]http://www.best-microcontroller-projects.com/pic16f84.html#Circuit_diagram[/LINK]
 

nerdegutta

Joined Dec 15, 2009
2,684
In the comment section of your program, it says:

Rich (BB code):
// Compiler : mikroC, mikroElektronika C compiler
//            for Microchip PIC microcontrollers
//            Version: 5.0.0.3
I think this little code will blink a LED on a PIC16F628.

Rich (BB code):
#include <htc.h> 
#define _XTAL_FREQ 4000000 
 
/* Configuration */ 
 
__CONFIG    (WDTDIS & 
            PWRTEN & 
            MCLREN & 
            BOREN & 
            LVPDIS & 
            DATUNPROT & 
            UNPROTECT & 
            XT); 
 
/* Prototyping the functions */ 
/*  For future references */ 
 
/* Global variables */ 
/*  For future references */
 
/* Main program */ 
void main() 
{ 
TRISA = 0b00000000;    // Setting all bits on port a to output
TRISB = 0b00000000;    // Setting all bits on port b to output 
 
PORTA = 0b00000000;    // Setting all bits on port a to LOW 
PORTB = 0b00000000;    // Setting all bits on port b to LOW 
 
CMCON = 0x07;    // Disabling the analogue comparators 
 
while (1) 
{ 
 
    PORTB = 0b00000001; // Setting bit 0 to HIGH 
    __delay_ms(1000); 
 
    PORTB = 0b00000000; // Setting all bits to LOW
    __delay_ms(1000); 
 
} // end while 
 
}  //end main
I don't think those two PIC are so different....
 

Thread Starter

Rk17

Joined Apr 23, 2011
43
will this work on a picF84A?

ive tried to compile it but it failed

Rich (BB code):
Error   [139] ; . end of file in comment
just this error though. please try to double chek it i i wanna give it a try if it works tnx
 

AlexR

Joined Jan 16, 2008
732
The config bit names are wrong. Also if you are using a PIC16F84A you need to comment out the line "CMCON = 0x07;" as that chip has no CMON register.
The code below should compile correctly.
Rich (BB code):
#include <htc.h> 
#define _XTAL_FREQ 4000000 
 
/* Configuration */ 
 
__CONFIG(WDTE_OFF & PWRTE_ON & CP_OFF & FOSC_XT); 
 
/* Prototyping the functions */ 
/*  For future references */ 
 
/* Global variables */ 
/*  For future references */
 
/* Main program */ 
void main() 
{ 
    TRISA = 0b00000000;    // Setting all bits on port a to output
    TRISB = 0b00000000;    // Setting all bits on port b to output 
    PORTA = 0b00000000;    // Setting all bits on port a to LOW 
    PORTB = 0b00000000;    // Setting all bits on port b to LOW  
 
    while (1) 
    { 
         PORTB = 0b00000001; // Setting bit 0 to HIGH 
        __delay_ms(1000); 
 
        PORTB = 0b00000000; // Setting all bits to LOW
        __delay_ms(1000); 
 
    } 
 
}
 
Top