title: STM32U575I-EV: While debugging I get an error and this function is called: void HardFault_Handler (void)
body: <p>The error is generated in this part of the code and precisely here:</p>
  <pre><code>writeVal[j] = RBF1[i+1];
  </code></pre>
  <p>I am attaching the code:</p>
  <pre class="lang-c prettyprint-override"><code>#define _FPGA_UPLOAD_C_
  
  #include &quot;globdefs.h&quot;
  
  
  extern SPI_HandleTypeDef hspi1;
  
  #define MEMORY_ADDR1 ((uint32_t)0x64000000) //FMC_BANK1_2
  
  const uint8_t RBF1[] ={0xA0,0xFF,0x02,0x6A,0xE7,0x82,0xF7,0x07,0xE7,0xF7,0xE7,0xF1,0xFB,0xF1,0xF9,0x82,0xFB,0x83,0xF9,0x08};
  
  
  
  uint16_t* fpgaRegx1 = (uint16_t*)FMC_BANK1_1; // FMC_BANK1_1: 0x60000000UL
  
  int8_t FPGA_Loading(char TypeRBF)
  {
  
      HAL_GPIO_WritePin(NCONFIG_CYCLONE_GPIO_Port,NCONFIG_CYCLONE_Pin, GPIO_PIN_RESET);
      Delay3micro();
      HAL_GPIO_WritePin(NCONFIG_CYCLONE_GPIO_Port,NCONFIG_CYCLONE_Pin, GPIO_PIN_SET);
      Delay3micro();
  
  
      int i=0;
      uint8_t* writeVal = (uint8_t*)(MEMORY_ADDR1 + sizeof(RBF1));
  
      uint16_t loadOK = 0;
  
      while (hspi1.State != HAL_SPI_STATE_READY)
      {};
  
      while (i &lt; sizeof(RBF1))
      {
          uint8_t n = RBF1[i] &amp; 0x7f;
          if (RBF1[i] &amp; 0x80)
          {
          
              for (int j=0; j&lt;n; j++){
  
                  writeVal[j] = RBF1[i+1];
              }
              i += 2;
          }
          else
          {
              for (int j=0; j&lt;n; j++)
                  writeVal[j] = RBF1[i+j+1];
              i += (n+1);
          }
  
          if(HAL_SPI_Transmit (&amp;hspi1, (uint8_t *) writeVal, n, 100)!=HAL_OK)
          {
  
              Error_Handler();
          }
      }
  
      Delay3micro();
      Delay3micro();
  
      HAL_SPI_MspDeInit(&amp;hspi1);  //spengo l'spi usata per la programmazione dell'fpga
  
      loadOK = fpgaRegx1[0];
      loadOK &amp;= 0xF000;
      if (loadOK == (uint16_t)0xA000)
      {
          loadOK=1;
      }
      else
      {
          loadOK=0;
          //Error_Handler();
      }
      return loadOK;
  }
  </code></pre>
  <p>I tried to generate a new, simpler project by inserting only the code I entered above and I don't get any errors. At this point I have always added on the new project through CubeIDE FILEX, THREADX and SDMMC1 the latter generates the same error written above. For FILEX, THREADX and SDMMC1 the code is only the one generated by CubeIDE.</p>