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.

Hi-Tech PIC Compiler Error, Cannot Find Header File

Status
Not open for further replies.

saifbd3344

Junior Member level 3
Joined
Apr 20, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Dhaka
Activity points
163
Code:
#include <htc.h>
#include "delay.h"
#define _XTAL_FREQ 8000000
void main()
{
  TRISB=0X00;
  PORTB=0X00;
  while(1)
  { 
    PORTB=0XFF;
    _delay_ms(100);
    PORTB=0X00;
    _delay_ms(100);
  }
}

but error please see attachment
Screenshot_1.png
 
Last edited by a moderator:

saifbd3344

Junior Member level 3
Joined
Apr 20, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Dhaka
Activity points
163
no browse from C:\Program Files (x86)\Microchip\MPLAB C30\src\peripheral_30F_24H_33F\include
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,349
Reputation
4,692
Reaction score
2,275
Trophy points
1,413
Location
Southwest, USA
Activity points
62,381
The header file, delay.h, cannot be found.

Where is it located relative to the main.c source file?

BigDog

- - - Updated - - -

no browse from C:\Program Files (x86)\Microchip\MPLAB C30\src\peripheral_30F_24H_33F\include


You are currently using the Hi-Tech PIC 10/12/16 Compiler and have selected the PIC16F877A as the current device.

So why are you looking in the C30, for PIC24 and PIC33/30?

Try changing the following:

Code:
#include "delay.h"

To:

Code:
#include <delay.h>


BigDog
 

saifbd3344

Junior Member level 3
Joined
Apr 20, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Dhaka
Activity points
163
Hello I just changed it but can't build.

Screenshot_1.png
 

poojarai

Newbie level 6
Joined
Dec 26, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,342
No need to include "delay.h" file instead you include controller file eg #include <pic16f886.h>. Also your delay syntax is also wrong ,it should be__delay_ms(100);
 

nagkiller

Full Member level 4
Joined
Jul 9, 2009
Messages
231
Helped
37
Reputation
74
Reaction score
37
Trophy points
1,308
Location
Brazil
Activity points
2,561
The files delay.h and delay.c is for hitech c for PIC18F!!!

In this case, you only comment or remove the #include delay.h, because it not exist in pic for PIC12/16F and your program works, because the #define _XTAL_FREQ 8000000

Change too the _delay_ms(100); to __delay_ms(100); (2 underlines).

Example:
Code:
#include <htc.h>
//#include "delay.h"
#define _XTAL_FREQ 8000000
void main(void){
	TRISB=0X00;
	PORTB=0x00;
	while(1)
	{
		PORTB=0xFF;
		__delay_ms(100);
		PORTB=0x00;
		__delay_ms(100);	
	}
}

PIC18 Delay.C
Code:
/*
 *	Delay functions
 *	See delay.h for details
 *
 *	Make sure this code is compiled with full optimization!!!
 */

#include	"delay.h"

void
DelayMs(unsigned char cnt) {
	unsigned char i;
	while (cnt--) {
		i=4;
		while(i--) {
			DelayUs(uS_CNT);	/* Adjust for error */
		} ;
	} ;
}

PIC18 Delay.H
Code:
/*
 *	Delay functions for HI-TECH C on the PIC18
 *
 *	Functions available:
 *		DelayUs(x)	Delay specified number of microseconds
 *		DelayMs(x)	Delay specified number of milliseconds
 *
 *	Note that there are range limits: 
 *	- on small values of x (i.e. x<10), the delay becomes less
 *	accurate. DelayUs is accurate with xtal frequencies in the
 * 	range of 4-16MHZ, where x must not exceed 255. 
 *	For xtal frequencies > 16MHz the valid range for DelayUs
 *	is even smaller - hence affecting DelayMs.
 *	To use DelayUs it is only necessary to include this file.
 *	To use DelayMs you must include delay.c in your project.
 *
 *	Set the crystal frequency in the CPP predefined symbols list
 *	on the PICC-18 commmand line, e.g.
 *	picc18 -DXTAL_FREQ=4MHZ
 *
 *	or
 *	picc18 -DXTAL_FREQ=100KHZ
 *	
 *	Note that this is the crystal frequency, the CPU clock is
 *	divided by 4.
 *
 *	MAKE SURE this code is compiled with full optimization!!!
*/

#define	MHZ	*1

#ifndef	XTAL_FREQ
#define	XTAL_FREQ	4MHZ		/* Crystal frequency in MHz */
#endif

#if	XTAL_FREQ < 8MHZ
#define	uS_CNT 	238			/* 4x to make 1 mSec */
#endif

#if	XTAL_FREQ == 8MHZ
#define uS_CNT  244
#endif

#if	XTAL_FREQ > 8MHZ
#define uS_CNT  246
#endif

#define FREQ_MULT	(XTAL_FREQ)/(4MHZ)

#define	DelayUs(x)	{ unsigned char _dcnt; \
			  if(x>=4) _dcnt=(x*(FREQ_MULT)/2); \
			  else _dcnt=1; \
			  while(--_dcnt > 0) \
				{\
				asm("nop");\
				asm("nop");\
				continue; }\
		} 

extern void DelayMs(unsigned char);

Sorry about the bad english, I am Brazilian, speak portuguese here!!! :???:
 

spudboy488

Full Member level 5
Joined
Oct 10, 2012
Messages
272
Helped
69
Reputation
140
Reaction score
75
Trophy points
1,308
Activity points
3,058
__delay_ms() and __delay_us() are macros on the PIC12/16 compiler. There is no header required. As nagkiller stated, use 2 leading underscores.
 

saifbd3344

Junior Member level 3
Joined
Apr 20, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Dhaka
Activity points
163
All are right but it is a new problem for windows-8.1. When I install mplab on c-rot directory then it was works.

Thanks All
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top