__delay_ms(); in MPLAB X IDE

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

__delay_ms(); in MPLAB X IDE

Postby redips_id » Thu Mar 08, 2012 11:13 pm

Hi Guys,

Untitled.png

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.
Request for complete solution for FYP? Why don't request for graduation certificate?
redips_id
Discoverer
 
Posts: 82
Joined: Wed Jan 20, 2010 6:23 pm

Re: __delay_ms(); in MPLAB X IDE

Postby robosang » Thu Mar 08, 2012 11:50 pm

Hi, which compiler? PIC16 with HI-Tech? or MPLAB C18?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: __delay_ms(); in MPLAB X IDE

Postby shahrul » Fri Mar 09, 2012 12:10 pm

__delay_ms() is for Hi-Tech. I'm not try with MPLab X yet.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: __delay_ms(); in MPLAB X IDE

Postby sich » Sun Mar 11, 2012 5:51 pm

Haven't migrate to mplabX... Did you successfully compiled the code? Is it only a warning? May be try to include delay.h?
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 604
Joined: Tue Apr 21, 2009 2:15 pm

Re: __delay_ms(); in MPLAB X IDE

Postby redips_id » Thu Mar 15, 2012 9:55 am

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.
Request for complete solution for FYP? Why don't request for graduation certificate?
redips_id
Discoverer
 
Posts: 82
Joined: Wed Jan 20, 2010 6:23 pm

Re: __delay_ms(); in MPLAB X IDE

Postby robosang » Fri Mar 16, 2012 6:59 pm

That's weird :)
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: __delay_ms(); in MPLAB X IDE

Postby yonghui » Thu Mar 22, 2012 11:24 am

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. :D


rgds,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: __delay_ms(); in MPLAB X IDE

Postby Brian Griffin » Thu Mar 22, 2012 12:05 pm

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.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: __delay_ms(); in MPLAB X IDE

Postby tonywk88 » Tue Apr 17, 2012 9:45 am

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
tonywk88
Newbie
 
Posts: 11
Joined: Tue Sep 27, 2011 9:37 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 0 guests