Page 1 of 1
__delay_ms(); in MPLAB X IDE

Posted:
Thu Mar 08, 2012 11:13 pm
by redips_id
Hi Guys,
It says "Unable to resolve identifier __delay_ms". Anyone experience it? How to resolve?
I used the same program in MPLAB IDE 8.83 and there have no problem.
Re: __delay_ms(); in MPLAB X IDE

Posted:
Thu Mar 08, 2012 11:50 pm
by robosang
Hi, which compiler? PIC16 with HI-Tech? or MPLAB C18?
Re: __delay_ms(); in MPLAB X IDE

Posted:
Fri Mar 09, 2012 12:10 pm
by shahrul
__delay_ms() is for Hi-Tech. I'm not try with MPLab X yet.
Re: __delay_ms(); in MPLAB X IDE

Posted:
Sun Mar 11, 2012 5:51 pm
by sich
Haven't migrate to mplabX... Did you successfully compiled the code? Is it only a warning? May be try to include delay.h?
Re: __delay_ms(); in MPLAB X IDE

Posted:
Thu Mar 15, 2012 9:55 am
by redips_id
I'm using MPLAB X IDE + Hi Tech C Compliler. It is only a warning, the compilation is successful. It is ok now after I define it.
#define delay_ms(x) __delay_ms(x)
However it is still a weird, it should be can be used directly without a warning.
Re: __delay_ms(); in MPLAB X IDE

Posted:
Fri Mar 16, 2012 6:59 pm
by robosang
That's weird

Re: __delay_ms(); in MPLAB X IDE

Posted:
Thu Mar 22, 2012 11:24 am
by yonghui
hi,
i also see this in mplabx. sometime also other variables shows this warning. however it will compile successfully, so i dont care it yet.

rgds,
yh
Re: __delay_ms(); in MPLAB X IDE

Posted:
Thu Mar 22, 2012 12:05 pm
by Brian Griffin
I used the Mplab X IDE and it compiles all-OK despite the __delay_ms() being underlined.
You may need to put "#define _XTAL_FREQ ________" (the empty blank is frequency in hertz) at the start of the code, though.
Re: __delay_ms(); in MPLAB X IDE

Posted:
Tue Apr 17, 2012 9:45 am
by tonywk88
Hi,
Add this code on top of your program.
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 20000000
#endif
#pragma inline(_delay)
extern void _delay(unsigned long);
#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
It should work after this.
Thanks