Keil - Embedded C program error

Discussion in 'Embedded Systems and Microcontrollers' started by JeffreyPeter, Jul 27, 2012.

  1. JeffreyPeter

    Thread Starter New Member

    Jul 25, 2012
    10
    0
    *** error 56: can't open file
    This error comes up when running.... Thx in advance
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Then show it the file... preferable while running.

    Running with scissors is discouraged, not files.
     
  3. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    Or try opening the file while walking.

    You definitely haven't given much to go on.

    Are you trying to open the file for reading or for writing? Is the device the file is on accessible? Is the file name legal? Does the file already exist? Is it write/read protected?

    I remember in the days of 360KB floppy drives, students would spend hours trying to figure out why they couldn't open a file and would come get me (my office was right next to the computer lab) and the problem was frequently that they hadn't turned the knob to close the drive. I remember one student was trying to write to a file and the disk had the write-protect tab on it. When I pointed this out, they said that they had been told that they should put that on there to prevent them from accidentally overwriting a file. When I said that they needed to take it off to write to the drive, they seemed confused. It turns out that because they were TRYING to write to the disk (i.e., it wasn't an 'accident'), that they didn't see why the tab being there should cause a problem.
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,420
    3,355
    One student couldn't read the floppy, which I soon discovered was inserted in the little crack between drive A and drive B.
     
  5. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    I never saw that, but I can SURE believe it!

    I have seen students try to write to a disk that was still in their back pack, though.
     
  6. JeffreyPeter

    Thread Starter New Member

    Jul 25, 2012
    10
    0
    Code ( (Unknown Language)):
    1. #include<reg52.h>
    2.  
    3. bit state=0;
    4. sbit ledPin = P1^5;
    5. void main()
    6. {          
    7.     int i,j;
    8.     while(1)
    9.     {
    10.         ledPin = 1;
    11.         for(i=0;i<1000;i++)
    12.         {
    13.             for(j=0;j<120;j++)
    14.             {
    15.             }
    16.         }
    17.         ledPin = 0;
    18.         }
    19.         for(i=0;i<1000;i++)
    20.         {
    21.             for(j=0;j<120;j++)
    22.             {
    23.             }
    24.         }
    25. }
    26.  
    *** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL
    SYMBOL: MAIN
    MODULE: C:\KEIL\C51\LIB\C51S.LIB (?C_INIT)
    ADDRESS: 0010H
    Program Size: data=10.1 xdata=0 code=194

    And this is the full program........
     
    Last edited by a moderator: Jul 28, 2012
  7. WBahn

    Moderator

    Mar 31, 2012
    17,715
    4,788
    It could be something in reg52.h.

    I'm not familiar with the syntax:

    sbit ledPin = P1^5;

    I assume that this is somehow defining ledPin to be bit 5 of P1? Seems like an awkward way to do it (since it would normally mean that you are initializing a variable of type sbit to be equal to the value of P1 (presumable some #define parameter) bitwise XOR'ed with the constant 5.

    How is the sbit type defined?

    How is P1 defined?
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I don't use those tools but... SYMBOL MAIN seems to be the problem. This may be due to the form of main() doesn't match what is expected.

    The first (and only) program for this has the following form for main():

    Code ( (Unknown Language)):
    1. void main(void)
    You may want to try the same. Compilers can be picky about these things.
     
Loading...