pic programming

Thread Starter

sumedha.roshan

Joined Jan 12, 2014
1
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.

Rich (BB code):
#include <htc.h>
#include <pic.h>
#define _XTAL_FREQ 4000000

int main(){
TRISB=0;
PORTB=0;
for(;;){
PORTB=1;
__DELAY_MS(3000);
PORTB=0;
__DELAY_MS(3000);
}
}
***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:

t06afre

Joined May 11, 2009
5,934
Rich (BB code):
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"
__delay_ms(x) // request a delay in milliseconds​
__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
 

tubeguy

Joined Nov 3, 2012
1,157
+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:

spinnaker

Joined Oct 29, 2009
7,830
+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.
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.
 

JohnInTX

Joined Jun 26, 2012
4,787
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:
Top