程序进入“HardFault_Handler”

2019-07-20 22:03发布



      初始化i2s3的dma通道后,程序进入了“HardFault_Handler”,我看了论坛上大家有的说是数组溢出了,我加大一倍的堆栈空间。另外重新定义了一个buf地址。但是没有解决这个问题。
      我的代码和调用如下:
"
I2S3_TX_DMA_Init((u8*)&i2spybuf1,(u8*)&i2spybuf2,1);
"
"
void I2S3_TX_DMA_Init(u8* buf0,u8 *buf1,u16 num)
{
        NVIC_InitTypeDef   NVIC_InitStructure;
        DMA_InitTypeDef  DMA_InitStructure;
       

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1,ENABLE);//DMA1±
       
        DMA_DeInit(DMA1_Stream5);
        while (DMA_GetCmdStatus(DMA1_Stream5) != DISABLE){}//DMA1_Stream5
               
        DMA_ClearITPendingBit(DMA1_Stream5,DMA_IT_FEIF5|DMA_IT_DMEIF5|DMA_IT_TEIF5|DMA_IT_HTIF5|DMA_IT_TCIF5);//DMA1_Stream5ù±ê

  /*  DMA Stream */

  DMA_InitStructure.DMA_Channel = DMA_Channel_0;
  DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&SPI3->DR;
  DMA_InitStructure.DMA_Memory0BaseAddr = (u32)buf0;
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
  DMA_InitStructure.DMA_BufferSize = num;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;        
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  //DMA_Init(DMA1_Stream5, &DMA_InitStructure);
       
        DMA_DoubleBufferModeConfig(DMA1_Stream5,(u32)buf1,DMA_Memory_0);

  DMA_DoubleBufferModeCmd(DMA1_Stream5,ENABLE);

  DMA_ITConfig(DMA1_Stream5,DMA_IT_TC,ENABLE);

        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}


    我标红注释的地方只要打开,就会进入“HardFault_Handler”。但是这样的话我的初始化等于没有完成。有没有哪位遇到过类似的问题的同仁指点一下。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。