mikroc compilation

Thread Starter

sankarigopal

Joined Apr 21, 2012
1
hello,

i am trying to compile a c code in mikroc and i am getting this error
C:/Users/pc/Documents/please.c:2: error: Can't open include file "htc.h"
my code is

Rich (BB code):
  #define _XTAL_FREQ 0x3D0900
#include <htc.h>

__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);

unsigned int tmr_ticked = 0;
bit volatile switch_debounced;


void interrupt my_int(void)
{
if(T0IE && T0IF)
{
//debouncing routine
tmr_ticked++;
if(tmr_ticked>4000)
{
PORTB = 0b00000000;
tmr_ticked=0;
switch_debounced=1;
RBIF=0; // ensuring this change is not picked up as an interrupt
}
T0IF=0;
}
if (RBIE && RBIF)
{
// Here interrupt from motion detector is treated as the switch
if( switch_debounced == 1)
{
//figuring out which switch is pressed and turning the right LED on
if(PORTB & 0b00010000)
{
PORTB=0b00001111;
switch_debounced=0;
tmr_ticked=0;
}
}
RBIF=0;
}

return;
// process other interrupt sources here
}

void init(void)
{
switch_debounced=1;
T0CS =0;
RBIE=1; //enable portb interrupts
PSA = 0;//Set prescaler to 1:256
PS0 = 0;
PS1 = 0;
PS2 = 0;
T0IE = 1; //Enable timer 1 interrupts
ei(); // initialising interrupts
// port directions: 1=input, 0=output
TRISB = 0b11110000;
PORTB=0b00001111;
switch_debounced=1;
}

void main(void)
{
init();
while (1)
{
}
}


please help
thanks

sankari
 
Last edited by a moderator:

CVMichael

Joined Aug 3, 2007
419
That code is not for mikroC compiler...

I use mikroC for some time now, and I can tell you that stuff like "__CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);" does not exists in mikroC.

Also, built in libraries in mikroC are included by checkmarking in the library manager. If the library is not built in, then you include it with "#include".

And by the way... did you know mikroC have their own forums ? http://www.mikroe.com/forum/
 

nerdegutta

Joined Dec 15, 2009
2,684
Since it cannot find the

Rich (BB code):
#include <htc.h>
I bet it is Hi Tech C code. Meant to be compiled in MPLAB Hi Tech C environment.
 
Top