Continue to Site

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
Junior Member level 3
Joined
Apr 20, 2014
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Dhaka
www.jannatun.com
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:

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
 

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);
 

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!!! :???:
 

__delay_ms() and __delay_us() are macros on the PIC12/16 compiler. There is no header required. As nagkiller stated, use 2 leading underscores.
 

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

Back
Top