+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Junior Member level 3
    Points: 505, Level: 4

    Join Date
    Apr 2014
    Location
    Dhaka
    Posts
    29
    Helped
    0 / 0
    Points
    505
    Level
    4

    Hi-Tech PIC Compiler Error, Cannot Find Header File

    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
    Click image for larger version. 

Name:	Screenshot_1.png 
Views:	12 
Size:	36.3 KB 
ID:	106319
    Last edited by alexan_e; 14th June 2014 at 16:06. Reason: added code tags

    •   Alt14th June 2014, 15:33

      advertising

        
       

  2. #2
    Junior Member level 3
    Points: 505, Level: 4

    Join Date
    Apr 2014
    Location
    Dhaka
    Posts
    29
    Helped
    0 / 0
    Points
    505
    Level
    4

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

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



    •   Alt14th June 2014, 17:04

      advertising

        
       

  3. #3
    Administrator
    Points: 68,974, Level: 64
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    bigdogguru's Avatar
    Join Date
    Mar 2010
    Location
    Southwest, USA
    Posts
    9,812
    Helped
    2350 / 2350
    Points
    68,974
    Level
    64
    Blog Entries
    4

    re: Hi-Tech PIC Compiler Error, Cannot Find Header File

    The header file, delay.h, cannot be found.

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

    BigDog

    - - - Updated - - -

    Quote Originally Posted by saifbd3344 View Post
    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
    The Edge... there is no honest way to explain it, because the only people who really know where it is are the ones who have gone over.
    -- Hunter S. Thompson



    •   Alt14th June 2014, 17:12

      advertising

        
       

  4. #4
    Junior Member level 3
    Points: 505, Level: 4

    Join Date
    Apr 2014
    Location
    Dhaka
    Posts
    29
    Helped
    0 / 0
    Points
    505
    Level
    4

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

    Hello I just changed it but can't build.

    Click image for larger version. 

Name:	Screenshot_1.png 
Views:	5 
Size:	38.0 KB 
ID:	106321



  5. #5
    Newbie level 6
    Points: 725, Level: 5

    Join Date
    Dec 2010
    Posts
    11
    Helped
    0 / 0
    Points
    725
    Level
    5

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

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



  6. #6
    Full Member level 4
    Points: 2,556, Level: 11
    Achievements:
    7 years registered
    nagkiller's Avatar
    Join Date
    Jul 2009
    Location
    Brazil
    Posts
    214
    Helped
    37 / 37
    Points
    2,556
    Level
    11

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

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



  7. #7
    Full Member level 4
    Points: 2,027, Level: 10

    Join Date
    Oct 2012
    Posts
    234
    Helped
    61 / 61
    Points
    2,027
    Level
    10

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

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



    •   Alt16th June 2014, 12:35

      advertising

        
       

  8. #8
    Junior Member level 3
    Points: 505, Level: 4

    Join Date
    Apr 2014
    Location
    Dhaka
    Posts
    29
    Helped
    0 / 0
    Points
    505
    Level
    4

    Re: Hi-Tech PIC Compiler Error, Cannot Find Header File

    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



--[[ ]]--