Delay function error in MPLAB X using hitech ccompiler PICC 9.83 plugin
2 posters
EMBEDDED FOR US :: EFU :: Discussions
Page 1 of 1
Delay function error in MPLAB X using hitech ccompiler PICC 9.83 plugin
Delay function error in MPLAB X using hitech ccompiler PICC 9.83 plugin gives error tell me what to do the code as under:
#include<htc.h>
#include<pic.h>
void main(void){
__delay_ms(50); //delay 50 ms
for(;;); //do forever
}
error: after compilation unable to resolve identifier
could anyone help!!!
#include<htc.h>
#include<pic.h>
void main(void){
__delay_ms(50); //delay 50 ms
for(;;); //do forever
}
error: after compilation unable to resolve identifier
could anyone help!!!
Skyfall- Posts : 4
Join date : 2012-08-16
Location : india
Delay function error in MPLAB X using hitech ccompiler PICC 9.83 plugin
do this add below code to main.c
- Code:
#include<PIC16F72.h>
#include"htc.h"
#include "delay.h"
void main(void) {
DelayMs(50); //delay
while(1);
}
- Code:
/*
* Delay functions for HI-TECH C on the PIC
*
* Functions available:
* DelayUs(x) Delay specified number of microseconds
* DelayMs(x) Delay specified number of milliseconds
*
* Note that there are range limits: x must not exceed 255 - for xtal
* frequencies > 12MHz the range for DelayUs is even smaller.
* 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 in
HPDPIC, or on the PICC commmand line, e.g.
picc -DXTAL_FREQ=4MHZ
or
picc -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!!!
*/
#ifndef DelayUs //-- Stop Multipule entrys of this code!!!
#ifndef XTAL_FREQ
#define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
#endif
#define MHZ *1000 /* number of kHz in a MHz */
#define KHZ *1 /* number of kHz in a kHz */
#if XTAL_FREQ >= 12MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)*((XTAL_FREQ)/12MHZ); \
while(--_dcnt != 0) \
continue; }
#else
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/(12MHZ/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
#endif
extern void DelayMs(unsigned char);
#endif
- 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)
{
#if XTAL_FREQ <= 2MHZ
do {
DelayUs(996);
} while(--cnt);
#endif
#if XTAL_FREQ > 2MHZ
unsigned char i;
do {
i = 4;
do {
DelayUs(250);
} while(--i);
} while(--cnt);
#endif
}
EMBEDDED FOR US :: EFU :: Discussions
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum