This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ferror takes the controller into Precise bus fault error

Dear All,
I have implemented flash file system on LPC1768. Creating, writing and reading files successfully.
If i try to open a file in read mode, a file that doesnt exist, then the controller goes into hardfault which is forced from precise bus fault error.

So, to stop my program from trying to read a file that doesnt exist, i used ferror as shown in the code below. But i m still getting an hardfault.


        parse_proto_name(LOAD_PROTOCOL);        //Get Protocol Name

        FileName = (char*)gProtocolName;
        fProtoName = fopen (FileName,"r");    //Open the File for reading

        if(ferror(fProtoName))
                return;         //Return if an error occured while trying to read a file.

        while(!feof(fProtoName))
        {
                temp = fread(&gTx0Buf[dtcntr], sizeof(char), 640, fProtoName);//Copy the file contents into TxBuf
        }
        fclose(fProtoName);

Details of variables

// Global Variables 
uint8_t gProtocolName[32]={0};  //To store the name of the protocol received from the display
FILE *fProtoName;

//Local Variables
uint8_t dtcntr;//data counter

Am i expecting too much from ferror & foef?

Parents Reply Children