Keil - Embedded C program error

WBahn

Joined Mar 31, 2012
27,934
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.
 

MrChips

Joined Oct 2, 2009
27,722
One student couldn't read the floppy, which I soon discovered was inserted in the little crack between drive A and drive B.
 

WBahn

Joined Mar 31, 2012
27,934
One student couldn't read the floppy, which I soon discovered was inserted in the little crack between drive A and drive B.
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.
 

Thread Starter

JeffreyPeter

Joined Jul 25, 2012
10
Rich (BB code):
#include<reg52.h>

bit state=0;
sbit ledPin = P1^5;
void main()
{          
    int i,j;
    while(1)
    {
        ledPin = 1;
        for(i=0;i<1000;i++)
        {
            for(j=0;j<120;j++)
            {
            }
        }
        ledPin = 0;
        }
        for(i=0;i<1000;i++)
        {
            for(j=0;j<120;j++)
            {
            }
        }
}
*** 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:

WBahn

Joined Mar 31, 2012
27,934
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?
 

ErnieM

Joined Apr 24, 2011
8,346
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():

Rich (BB code):
void main(void)
You may want to try the same. Compilers can be picky about these things.
 
Top