mikroc compilation

Discussion in 'Programmer's Corner' started by sankarigopal, Apr 21, 2012.

  1. sankarigopal

    Thread Starter New Member

    Apr 21, 2012
    1
    0
    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

    Code ( (Unknown Language)):
    1.  
    2.   #define _XTAL_FREQ 0x3D0900
    3. #include <htc.h>
    4.  
    5. __CONFIG(XT & WDTDIS & PWRTDIS & UNPROTECT);
    6.  
    7. unsigned int tmr_ticked = 0;
    8. bit volatile switch_debounced;
    9.  
    10.  
    11. void interrupt my_int(void)
    12. {
    13. if(T0IE && T0IF)
    14. {
    15. //debouncing routine
    16. tmr_ticked++;
    17. if(tmr_ticked>4000)
    18. {
    19. PORTB = 0b00000000;
    20. tmr_ticked=0;
    21. switch_debounced=1;
    22. RBIF=0; // ensuring this change is not picked up as an interrupt
    23. }
    24. T0IF=0;
    25. }
    26. if (RBIE && RBIF)
    27. {
    28. // Here interrupt from motion detector is treated as the switch
    29. if( switch_debounced == 1)
    30. {
    31. //figuring out which switch is pressed and turning the right LED on
    32. if(PORTB & 0b00010000)
    33. {
    34. PORTB=0b00001111;
    35. switch_debounced=0;
    36. tmr_ticked=0;
    37. }
    38. }
    39. RBIF=0;
    40. }
    41.  
    42. return;
    43. // process other interrupt sources here
    44. }
    45.  
    46. void init(void)
    47. {
    48. switch_debounced=1;
    49. T0CS =0;
    50. RBIE=1; //enable portb interrupts
    51. PSA = 0;//Set prescaler to 1:256
    52. PS0 = 0;
    53. PS1 = 0;
    54. PS2 = 0;
    55. T0IE = 1; //Enable timer 1 interrupts
    56. ei(); // initialising interrupts
    57. // port directions: 1=input, 0=output
    58. TRISB = 0b11110000;
    59. PORTB=0b00001111;
    60. switch_debounced=1;
    61. }
    62.  
    63. void main(void)
    64. {
    65. init();
    66. while (1)
    67. {
    68. }
    69. }
    70.  


    please help
    thanks

    sankari
     
    Last edited by a moderator: Apr 21, 2012
  2. CVMichael

    Senior Member

    Aug 3, 2007
    416
    17
    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/
     
  3. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Since it cannot find the

    Code ( (Unknown Language)):
    1. #include <htc.h>
    I bet it is Hi Tech C code. Meant to be compiled in MPLAB Hi Tech C environment.
     
Loading...