1. sumedha.roshan

    Thread Starter New Member

    Jan 12, 2014
    I am new to pic programming. I am using MPLAB IDE v8.76 and tried to make a program as i seen in a website. it is as below.

    Code ( (Unknown Language)):
    2. #include <htc.h>
    3. #include <pic.h>
    4. #define _XTAL_FREQ 4000000
    6. int main(){
    7. TRISB=0;
    8. PORTB=0;
    9. for(;;){
    10. PORTB=1;
    11. __DELAY_MS(3000);
    12. PORTB=0;
    13. __DELAY_MS(3000);
    14. }
    15. }
    ***but it giving error massage as below. i tried changing such as DELAY_MS, _delay_ms, delay_ms etc; but failed. please can somebody help me.

    Build E:\Users\ACMA\my project\led blink2 for device 16F628A

    Using driver C:\Program Files\HI-TECH Software\PICC\9.83\bin\picc.exe

    Make: The target "E:\Users\ACMA\my project\led blink2.p1" is out of date.

    Executing: "C:\Program Files\HI-TECH Software\PICC\9.83\bin\picc.exe" --pass1 "E:\Users\ACMA\my project\led blink2.c" -q --chip=16F628A -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] E:\Users\ACMA\my project\led blink2.c; 10.1 function declared implicit int
    Executing: "C:\Program Files\HI-TECH Software\PICC\9.83\bin\picc.exe" "-oled blink2.cof" "-mled blink2.map" --summary=default --output=default "led blink2.p1" --chip=16F628A -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 (Lite Mode) V9.83

    Copyright (C) 2011 Microchip Technology Inc.

    (1273) Omniscient Code Generation not available in Lite mode (warning)

    Error [499] ; 0. undefined symbol:

    ___DELAY_MS(led blink2.obj)

    ********** Build failed! **********
    Last edited by a moderator: Jan 12, 2014
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    Code ( (Unknown Language)):
    2. C is case sensetive so the correct form is as shown (lower case) but yes it TWO under scores! This is according to the manual in the folder "....\HI-TECH Software\PICC\9.83\docs"
    3. [LEFT]__delay_ms(x) // request a delay in milliseconds[/LEFT]
    4. __delay_us(x) // request a delay in microseconds
    Be aware that 3000 msecond may be a to long delay. If you use a to long delay the compiler will give an error message but somewhat cryptic. What about the configuration bits. Have you given them some thinking. If these bits are not set properly. Nothing will happen then you try to run the code in your PIC
  3. tubeguy

    Well-Known Member

    Nov 3, 2012
    +1 Does the value need to be 255 or less?
    Looking at the error printout, I think you may have three leading underscores instead of two.
    Last edited: Jan 12, 2014
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    Depending on the speed of the clock and how the code was written, it might even need to be less than that. You will have to group calls to your delay function for longer delays.
  5. JohnInTX


    Jun 26, 2012
    From the users manual pp 168
    __delay_ms(x) has 2 underscores and is lower case. Its a macro that wraps around _delay(unsigned long Tcyc) which is an inline function.

    From your code and list of things tried it looks like you've misspelled the macro or the upper case is fouling the works. You should be able to get 3000ms since 3E6 Tcyc fits into the 32 bit unsigned long.

    Be sure you have correctly spelled the system clock speed (which it looks like you have done).

    Don't forget that when you program the chip, you'll need to specify the CONFIG registers to match the oscillator type, etc.
    Last edited: Jan 12, 2014