Page 1 of 1

What is error in this?

PostPosted: Sat Jul 28, 2018 1:55 pm
by LED
Hello
What is error in this code i am using hi tech c compiler
Code: Select all
#include <htc.h>

#define _XTAL_FREQ 2000000
void main()
{
  TRISB=0x00;
 
  while(1)
  {
    PORTB=0xf0;
 PORTB=0x0f;
__delay_ms(10);
}
}


HI-TECH PICC-Lite COMPILER (Microchip PICmicro) V9.50PL2
Copyright (C) 1984-2006 HI-TECH SOFTWARE
Error [499] ; . undefined symbol:
___delay_ms (INDIAA.obj)

Re: What is error in this?

PostPosted: Sat Jul 28, 2018 4:57 pm
by vloki
Any reason to use old HI-TECH Lite compiler and not actual xc8?

Re: What is error in this?

PostPosted: Sat Jul 28, 2018 8:53 pm
by Jorgef
Hi

If the compiler doesn't recognise the "__delay_ms" symbol its a syntax error, assuming HTC has such a delay macro/function.
Check the manual to see the exact syntax for it.
Almost all PIC compilers I've seen have some form of "delay" macro, but they vary in details like the presence and number of underscores in the name.

Re: What is error in this?

PostPosted: Sun Jul 29, 2018 4:39 am
by jtemples
The older Hi-Tech compilers (including 9.50) do not have any built-in delay functions. You are trying to take something from XC8 and use it with Hi-Tech. There are some delay functions in the samples directory if you really must use Hi-Tech, but you should be using XC8.

Re: What is error in this?

PostPosted: Mon Jul 30, 2018 3:44 am
by ric
FYI, I have just moved this topic from the "USB" forum to the "HI TECH C" forum.
LED, the copyright message is a hint that you are using an ancient compiler. "Copyright (C) 1984-2006 HI-TECH SOFTWARE"

Re: What is error in this?

PostPosted: Mon Jul 30, 2018 3:57 pm
by Jorgef
Hi

PIC10/12/16 or PIC18?

Re: What is error in this?

PostPosted: Tue Jul 31, 2018 8:38 am
by LED
PIC16

Re: What is error in this?

PostPosted: Tue Jul 31, 2018 11:39 am
by ric
LED, you've been asked several questions in this topic, and only answered one.

Re: What is error in this?

PostPosted: Tue Jul 31, 2018 10:54 pm
by Jorgef
Hi

Curious.
I have here an "Hitec C for PIC 10/12/16 users's guide" by Microchip (DS51865B from 2010) that clearly states the existence of "__delay_ms(x)", "__delay_us(x) as "macros" dependent on the definition of "_XTAL_FREQ", also a "_delay(unsigned long cycles)".
Compiler version is 9.83

The Hitec-C for PIC18, version 9.80 only has the last one (cycles).

Unfortunattley I don't have this toolchains configured in MPLAB so I can't make a test myself.

It might be dificult to find a newer version fo the HTC compiler, so I suggest you move to its direct descendant XC8.