vinodstanur
Advanced Member level 3
- Joined
- Oct 31, 2009
- Messages
- 751
- Helped
- 114
- Reputation
- 234
- Reaction score
- 114
- Trophy points
- 1,333
- Location
- Kerala (INDIA)
- Activity points
- 7,054
NerdKits
#include <htc.h>
#define _XTAL_FREQ 4e6 // 4MHz
void main( void )
{
_delay( 1 ); // 1 instruction cycle delay
__delay_us( 2 ); // 2 us delay
__delay_ms( 3 ); // 3 ms delay
}
Impressive, how they finally catch up with the competitionA new built-in inline function '_delay' had been offered by HI-TECH C for PIC10/12/16 v9.60+ PRO mode
These routines are not working ...please help!Code:
#include <htc.h>
#define _XTAL_FREQ 4e6 // 4MHz
void main( void )
{
_delay( 1 ); // 1 instruction cycle delay
__delay_us( 2 ); // 2 us delay
__delay_ms( 3 ); // 3 ms delay
}
// hi-tech c compiler for PIC12F629
#include <htc.h> // Required to interface with delay routines
#ifndef _XTAL_FREQ
// Unless already defined assume 4MHz system frequency
// This definition is required to calibrate __delay_us() and __delay_ms()
#define _XTAL_FREQ 4000000
#endif
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & BOREN_OFF & CP_OFF & CPD_OFF);
void main(void){
while(1)
{
GPIO=0;
__delay_ms(500);
GPIO=0xFF;
__delay_ms(500);
}
}
These routines are not working ...please help!
#include<htc.h>
#define _16F877
__CONFIG( HS & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
#define XTAL_FREQ 12MHZ
void main()
{
TRISB=0x00;
TRISD=0x00;
while(1)
{
PORTB=0xff;
PORTD=0xff;
__delay_ms( 3 );
PORTB=0x00;
PORTD=0x00;
__delay_ms( 3 );
}
}
Error [192] E:\led.c; 14.29 undefined identifier "_XTAL_FREQ"
********** Build failed! **********
#define XTAL_FREQ 12000000 // 12 MHZ
or
#define XTAL_FREQ 12
or
#define PIC_CLK 12
Code:#define XTAL_FREQ 12MHZ
This my code and am using MPLAB IDE v8.60 with HI-TECH compiler 9.60.
I have type the delay routines as you said but the compiler gave the following errors
Error [192] E:\led.c; 14.29 undefined identifier "_XTAL_FREQ"
********** Build failed! **********
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?