AnsweredAssumed Answered

Hard fault Exception when bus fault exception occured

Question asked by Mahabir Prasad on Dec 31, 2012
Latest reply on Jan 19, 2013 by Mahabir Prasad
Dears,
I have problem while debuging the code for STM32L151RDT6. I get every time the hard fault exception with bus fault.
Description of Project:
I am using KEIL 4.54 with ST Link/V2. The system has SPI FLash (8MB from winbond), uses embedded Flash file System without RTX. The stack size is 2K and Heap is 1K. The startup file have not changed except the sizes as above mentioned, supplied by KEIL along with compiler. I uses ADC1 and USB(Device), USB_LP_IRQ along Systick in application. I have assigned the Priority group1 with ADC1 (0,0) and USB (0, 1) priority (Prempt priority, sub priority). FOr USB, I uses CDC class and send the packets of 64 bytes. As long I read the settings from RAM, I do not have any problem, but whenever I send the command to read the stored file in SPI flash, I get the problem while opening the file. While reading on internet and blogs, book by Joseph Yiu. I got confused and did not able to find real reason.
I included the screen shots of code, registers and other things whatever possible. Pleae let me where is problem, what is going wrong with code which generate the exception and system goes out of order(Do I need RTX with file system?)
Explanation of pdf file
1. Page one show the status while entering in the main program.
2. Page two, has break point on fopen command, which generate the problem.
3. Page three, has subfunction fopen (library of KEIL)
4. Page four, status of system when Exception occured.

Below is c statement of file. I also get the same exception some time, in this case, also it is by fopen command (to append the file).
In stated case, I get problem 100%. The bus fault error address is out of address range, which is not understandable.

FFS_EXTERN  void  FFS_vReadFile(char *par)
{
  FILE *f;
  char *fname, *next;

  ulword    ulSize;
  char aubText[68];
    
  fname = get_entry(par, &next);

  if(fname == NULL)
  {
    KEY_vMSGDisplay2(KEY_FILE_NAME_MISS);
    strncpy(aubText,"File Name missing.\n\r", sizeof(aubText));
    USB_vTxmtString((const char *)aubText);
    return;
  }

  f = fopen(fname, "r");            /* open the file for reading          */

  if(f == NULL)
  {
    KEY_vMSGDisplay2(KEY_FILE_NOT_FOUND);
    strncpy(aubText,"File not found!\n\r", sizeof(aubText));
    USB_vTxmtString((const char *)aubText);
  }

so on further.



Attachments

Outcomes