cannot open header file

Discussion in 'Embedded Systems and Microcontrollers' started by kael, Aug 16, 2010.

  1. kael

    Thread Starter New Member

    Nov 8, 2009
    1
    0
    Hi,
    I am trying to see whether or not I setup the configuration of the 18F4520 pic properly for PWM. The code below is what i used: (I am using C18 C complier)

    #include <p18f4520.h>

    #pragma config OSC = INTIO7
    #pragma config WDT = OFF
    #pragma config LVP = OFF
    #pragma config IESO = ON
    #pragma config PWRT = ON
    #pragma config BOREN = OFF
    #pragma config MCLRE = ON
    #pragma config CP0 = OFF
    #pragma config PBADEN = OFF
    #pragma config DEBUG = OFF

    void main ()
    {
    TRISB = 0x00;

    OSCCON = 0x7f;

    ADCON1 = 0x01;
    CMCON = 0x00;

    PR2 = 0x31;
    T2CONbits.TMR2ON = 1;
    CCPR2L = 0x1F;
    CCP2CONbits.CCP2M2 = 1;
    CCP2CONbits.CCP2M3 = 1;

    while (1)
    {
    PORTB = 0xFF; // dont worry about this, was part of another test
    }
    }


    This builds ok, but when i try to simulate with proteus the PWM doesnt work. further investigation shows that when i attempt to assemble the code i get the following errors:

    Executing: "C:\MCC18\mpasm\mpasmwin.exe" /q /p18F4520 "test.c" /l"test.lst" /e"test.err" /o"test.o" /d__DEBUG=1
    Error[105] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 1 : Cannot open file (Include File "p18f4520.h" not found)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 3 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 4 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 5 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 6 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 7 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 8 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 9 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 10 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 11 : Illegal label (#pragma)
    Error[121] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 12 : Illegal label (#pragma)
    Error[122] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 14 : Illegal opcode (main)
    Error[108] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 15 : Illegal character ({)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 16 : Found label after column 1. (TRISB)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 18 : Found label after column 1. (OSCCON)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 20 : Found label after column 1. (ADCON1)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 21 : Found label after column 1. (CMCON)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 23 : Found label after column 1. (PR2)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 24 : Found label after column 1. (T2CONbits.TMR2ON)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 25 : Found label after column 1. (CCPR2L)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 26 : Found label after column 1. (CCP2CONbits.CCP2M2)
    Warning[207] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 27 : Found label after column 1. (CCP2CONbits.CCP2M3)
    Error[129] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 34 : Expected (ENDW)
    Error[129] C:\USERS\KEAT\DESKTOP\MPPT PROJECT\C2\TEST.C 35 : Expected (END)


    I am guessing this is the root of the problem, but having searched the internet and followed many solutions. they just dont work for me. I ensured that project > build options > project setting are all correct.... Can anyone shed some light on this problem?
     
    Last edited: Aug 16, 2010
  2. zxsa

    Member

    Jun 11, 2010
    31
    2
    Assemble? You don't "assemble" C-source - you compile (build) it.

    I'm not familiar with the MPLAB C18 compiler, but I would expect the command to run it to be something like "mpc18.exe" rather than "mpasmwin.exe". Make sure you are using a C-tool and not an assembler tool.
     
  3. vantusaonho

    New Member

    Apr 28, 2010
    7
    0
    It can be your PC have infected by virus, Virus did hide permanent folder of C compiler
     
Loading...