FSMC在STM32F4上给出了硬故障处理程序

时间:2017-09-08 14:23:32

标签: c stm32 stm32f4discovery stm32f4

我目前正在开展一个项目,我尝试将数据从FPGA发送到ARM处理器(STM32F407)。我试图通过使用FSMC来实现这一点,在那里我将FPGA模拟为从处理器看到的闪存。我需要使用FSMC,因为FPGA会从传感器和两个GPS中采集大量数据。

当我使用函数HAL_NOR_Read()时,代码崩溃到HardFault_Handler

FSMC配置为8位多路复用的非闪存存储器。FSMC config

我正在使用TrueStudio对STM32F4进行编程,并在代码崩溃之前使用调试器来完成汇编代码。但我不认为我有知识在那里找到错误。

也许其他人有更多的知识可以帮助我解决问题。

以下是我使用的代码。

#include "main.h"
#include "stm32f4xx_hal.h"

SD_HandleTypeDef hsd;

UART_HandleTypeDef huart4;
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart3;

NOR_HandleTypeDef hnor1;
FMC_NORSRAM_TimingTypeDef Timing;

#define NOR_BANK_ADDR ((uint32_t *)0x64000000)
#define BUFFER_SIZE ((uint32_t)16)
uint16_t aRxBuffer[BUFFER_SIZE] = {0};

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_FSMC_Init(void);
static void MX_SDIO_SD_Init(void);
static void MX_UART4_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART3_UART_Init(void);


int main(void)
{
  HAL_Init();
  SystemClock_Config();

  MX_GPIO_Init();
  MX_FSMC_Init();
  MX_SDIO_SD_Init();
  MX_UART4_Init();
  MX_USART1_UART_Init();
  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */
  HAL_NOR_Init(&hnor1,&Timing,&Timing);

  HAL_NOR_Read(&hnor1,NOR_BANK_ADDR,aRxBuffer);


  while (1)
  {    
  }  
}

这是FSMC的参数

static void MX_FSMC_Init(void)
{
  FSMC_NORSRAM_TimingTypeDef Timing;

  /** Perform the NOR1 memory initialization sequence
  */
  hnor1.Instance = FSMC_NORSRAM_DEVICE;
  hnor1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
  /* hnor1.Init */
  hnor1.Init.NSBank = FSMC_NORSRAM_BANK1;
  hnor1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_ENABLE;
  hnor1.Init.MemoryType = FSMC_MEMORY_TYPE_NOR;
  hnor1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_8;
  hnor1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_ENABLE;
  hnor1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
  hnor1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
  hnor1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
  hnor1.Init.WriteOperation = FSMC_WRITE_OPERATION_DISABLE;
  hnor1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
  hnor1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
  hnor1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
  hnor1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
  hnor1.Init.PageSize = FSMC_PAGE_SIZE_NONE;
  /* Timing */
  Timing.AddressSetupTime = 15;
  Timing.AddressHoldTime = 15;
  Timing.DataSetupTime = 255;
  Timing.BusTurnAroundDuration = 15;
  Timing.CLKDivision = 16;
  Timing.DataLatency = 17;
  Timing.AccessMode = FSMC_ACCESS_MODE_A;
  /* ExtTiming */

  if (HAL_NOR_Init(&hnor1, &Timing, NULL) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}

0 个答案:

没有答案